This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Conditionals & Control Flow Forum

View Course

2719 points
50b7d7b3cf6c0f9b11000087_795211733
Submitted by
Eric Weinstein
over 3 years ago

The Big If

Hi everyone!

First, my apologies for the confusion surrounding the exercise The Big If. The below should help clear things up:

  1. Python doesn't like mixed spaces and tabs when you indent a line. For that reason, it's best to use four spaces (not the tab key!) when indenting. This forum answer should help you if you think indentation is the problem.
  2. The exercise is looking for a properly indented if/elif/else with at least one comparison (<=, >=, <, >, !=, or ==) and one boolean operator (and, or, or not). When indenting, make sure to indent the same amount on the line after each colon!
  3. Whatever your if/elif/else evaluates to should be True. Here's an example of an if/elif/else that does all of the above, only I've left out the boolean operator requirement (since otherwise you could just cut/paste this answer!):

if 1 < 2:                # This is true...
    return True          # so True will be returned!
elif 1 > 2:
    return False
else:
    return False

For the boolean part, you can just use something like if True and True (which is True) or if not True (which is False) to meet all the requirements of the lesson.

I hope this helps, and apologies again for the confusion!


43 votes

permalink

A lot of those answers here are helpful yet I might help someone but putting my solution as well.

 def theflyingcircus():
    if 9 <= 9:
        return True
        print "It's true"
    elif 6 == 8 or 99 < 88:
        return False
    else:
        return False

now as you know the positioning is crucial in python therefore be aware of that in every single move. if, elif and else is moved only by SPACEBAR (no Enter, no Tab). with the return and print I used Enter right after colon ":"
double-check the spaces. it took me a lot of time to do this exercies, but for your own sake, do not copy&paste it.

481 points
517961bdc11e35cfbe00038d_918389170
Submitted by
Jakub Zachnik
about 3 years ago

17 Comments

51e97cd18c1ccc598600329e_362688789 Sharan Reddy almost 3 years ago

is it necessary that we need to use print over there?

52083cb5f10c6091ba005e4d_255942379 godhatedices. almost 3 years ago

no it is not

B1fa139883c091f8a724147a693713af?s=140&d=retro muugii_k23 almost 3 years ago

it is work tnx

3a0f523d5e3647b5cfb6839739a10ec9?s=140&d=retro Derek C over 2 years ago

Another problem with good coding going bad umm well i have pretty much the exact same thing but it is throwing mine out for no bool operators when i do i am confused at why and i was wondering if someone might have an answer

3e615d6d5c73dba83ca21b397a9520f6?s=140&d=retro FnRPJs over 2 years ago

I was getting so angry so i copy and pasted this and it still did not work. Turns out I needed to refresh my browser. So I used this and then went back and did my own to make sure I knew what I was doing....so if you get stuck and you swear your code is right then just refresh the page and try it again. (I'm using Firefox)

52c0cf227c82ca009d00660c_806009260 Chris Bennett over 2 years ago

Thank you so much!

524838e8abf82174930038b4_774268263 Abu-Bakr over 2 years ago

you so save the day!

3a31e7ddd29bccd5cfdd9ecafa7a9d95?s=140&d=retro Mzuslin over 2 years ago

this is really helpful !thx!!!

52ca366b548c35a5f5000f54_115938807 the analist over 2 years ago

I COPY THIS AND GET SOOO MUCH GOOD NICE THINGS

52ef60e6548c35dc420000d0_494091711 gunther over 2 years ago

omg ive been struggling for ages thank you so much love you long time youve completed my life

Cbcc345da07f6d49068690428c62404b?s=140&d=retro yassinebouzbiba over 2 years ago

Thank you sir :0

52ef60e6548c35dc420000d0_494091711 gunther about 2 years ago

danny no one cares

F8f5dd85790e7dca591d7bb17dedaecf?s=140&d=retro Yrael about 2 years ago

i am having problems with indentation i didnt put in. eg it will tell me the indent on the elif statemnet is wrong even though it was there already.

531449ac7c82cab1500099f2_931695622 surfer about 2 years ago

indent was my problem 2 ;solved!guys never forget to code in the right line

56b382700955cde854000189_210540302 Anonymous about 2 years ago

dosent work

866cbc36b533a5cdb7c264dc7bb67592?s=140&d=retro aputsey about 2 years ago

lol refreshing worked!

4029c38051db2b359d69817e3e55cd0a?s=140&d=retro Steven Musante about 2 years ago

Thank you I was totally lost


28 votes

permalink

i learned more from researching why this didn't work than had it worked.

37 points
D2930e855165ab376f4e7ecdab69d6b2?s=140&d=retro
Submitted by
monty.wolf
about 3 years ago

1 Comment

9e7a84cf432537f861aab0be24a8780b?s=140&d=retro Christopher over 2 years ago

Same Here. Poor examples and explination!


13 votes

permalink

@Davide:

Rather than cutting/pasting, try typing the code out with exactly the same formatting as shown. Cutting/pasting may change the indentation of the lines, which will cause Python to raise an error.

2719 points
50b7d7b3cf6c0f9b11000087_795211733
Submitted by
Eric Weinstein
over 3 years ago

20 Comments

510c313ce42722acec003a38_175505087 Kristofer Smith over 3 years ago

Its about time we get feedback from the people how wrote these lousy codes.

5126f4accc7bb8762200001a_290845725 c0deninja over 3 years ago

Don't stress. Count yourself lucky to be using this free service maintained mostly by kind people volunteering their time.

510c313ce42722acec003a38_175505087 Kristofer Smith over 3 years ago

It says they are hiring, so they can go blow me for all I care.

51269741277694c1320006c4_456943418 Madura Balasubramanian over 3 years ago

Hey I tried that, still not working! Could you tell me how to fix it?

A19dbd5560d594e29776f86f19c6b194?s=140&d=retro Shannon Gibson about 3 years ago

They may be hiring, but this is still a free service...

513904104790eeaf81007e1f_651919670 Chris Stanchak about 3 years ago

OMFG that was annoying. Thank God I found this post. Four spaces...not a tab. I think that should be somewhere in the tutorial...no?

62de89484fc524b20907375858e0e6bf?s=140&d=retro kirsche17 about 3 years ago

Hey everybody! I just spent three hours trying everything to make this work! For me it worked like this: if 1 < 2 #four spaces in front of "if"!!! return True #six spaces in front of "return"!!! --> It was just about the right number of spaces in front of the "if" and "return"!

514214c02da5dde932000a03_105602943 SalceKosma_4fb9dd5d684a3300030022d2_ about 3 years ago

Hi Eric, why Python has such a problem between spaces and tab? Interesting...

C9196fe362df84d56a6f622bb711f18a?s=140&d=retro thewelshgreen about 3 years ago

I could swear that in the tutorial it said tab, not four spaces. Now it's the other way around? What? I dont-? WTH?

704c29d6c9208849f6073204422dfe56?s=140&d=retro Skye Margot Mazur about 3 years ago

I think my spacing is fine here. I've got all the requirements. My error message just reads "Oops try again/true"

def theflyingcircus():
answer == "Yes"
if answer == "Yes":
return True
elif answer == "Yes" or "No":
return False
else:
return True

516d8233015e3dd14b000c1a_384730478 Cole Florence about 3 years ago

+1

94a087a879e4bf5df72e19805c99eddd?s=140&d=retro floris15 about 3 years ago

this new editor doesn't help. prefered the old one

Default_user anonymous about 3 years ago

HEY GUYS ITS captainsparkelz

516d8233015e3dd14b000c1a_384730478 Cole Florence about 3 years ago

No. Your not captainsparkelz

51c1ceb19c4e9d835000d04d_977820090 Seamus Cusack almost 3 years ago

Thanks Eric. The bit of info that got mine to work is " When indenting, make sure to indent the same amount on the line after each colon! "

52083cb5f10c6091ba005e4d_255942379 godhatedices. almost 3 years ago

don't mean to intrudes, but to be more specific, one of each should be selected ( == or !=, < or >, => or <=.) throughout if/elif/else statements in order to satisfy this exercise.

52001e83abf821eb040003bf_136482551 Zachary Jeans almost 3 years ago

I think incorporating the 'print' function would be helpful req.

2ee4c24d9c13a5c784f6c8d591cccaf4?s=140&d=retro pbs257 almost 3 years ago

This assignment doesn't accept any valid solution for me. Quite frustrating. I am unable to continue...

0c8465069323aa9e7236b9083da3b43c?s=140&d=retro yateendraji over 2 years ago

Eric: So glad you explained this. I was really scratching my head when my script worked in "real" python and not in the exercise. You explained why...

988b5dc7be9fdd7cf72b8986acb5e3f6?s=140&d=retro chych84 over 2 years ago

(: haha,I misunderstanding that the four spaces are in front of the "if" at first, so~ :( But now, it's ok! I'm so happy! Thank you!


8 votes

permalink

FWIW, my problem was with return keyword. I only saw it in the early examples and it was never explained the way that the print command was.

My first (failed) code here was:

def the_flying_circus():
    if 226 == 226:
        print "226 is teh ossum."
    elif True and False:
        print "is not true"
    else:
        print "and nope"

After eventually looking at the correct answers here and just trial and erroring, I finally added the return commands and made it work:

def the_flying_circus():
if 226 == 226:
    return True
    print "226 is teh ossum."
elif True and False:
    return False
    print "is not true"
else:
    return False
    print "and nope"

What's odd about this lesson is that until now we've had Python do the work for us with regard to math and logic; suddenly here we're 'returning' the answer to...I don't know who the answer returns to.

Good luck repairing this exercise! Love the course anyway.

392 points
555653e2d3292f90130006f4_806795345
Submitted by
Anthony Sims
over 2 years ago

5 Comments

0fb1df92c34cb8fbb452422697013925?s=140&d=retro Schakra about 2 years ago

Same issue here.
The "return" must be explained earlier.

F9cdce98dd384c3a2b086c90e1325681?s=140&d=retro rubyJumper18927 about 2 years ago

Ditto! I actually tried using return even though it bothered me it hadn't been explained - was still getting an error but suppose it's the indentation thing explains it. Thanks.

Dcf2adca668f70a844babd91f27b2c87?s=140&d=retro hoop4848 about 2 years ago

GOD BLESS YOU! I've tried everyone elses code and it wont work, but yours did!

533ab89e548c35ba26001286_768807675 Anonymouse about 2 years ago

Yes!! Thank you!!

E33816912058cd3d9024c59f5321427b?s=140&d=retro 曉瑩劉 about 2 years ago

Thank you very much!!!It is really helpful!!!


5 votes

permalink

a = "lets do it"
def theflyingcircus():

 if a == "lets do it":
   return True
 elif True and False:
   return False
 else: 
   return False

662 points
514bdb6fa2c3ac92bc000a7e_338009103
Submitted by
Nitish Murthy
about 3 years ago

11 Comments

5154f64b41245bf2a4000012_962084104 Ajinkya Rane about 3 years ago

This works with copy and paste! Thanks!

51ce9d8e282ae3d4c3002336_683479373 Kelvin Yin about 3 years ago

Thanks ! It really works :D

55d82ca0e39efe6dc900013e_899919726 nobody can know about 3 years ago

thanks is work

Dd307037d3b9999a616db992cb1ac86b?s=140&d=retro kachigar about 3 years ago

wow! finally!

6607e7bc55c4fc434f16d7b3b2745d57?s=140&d=retro Mouse almost 3 years ago

save me thanks you

51ea4c7752f86395e90024fc_182676277 Zaidhan almost 3 years ago

it works thanks

5bfc8f911899d647f6f209263cd7a3ad?s=140&d=retro grinfable almost 3 years ago

omg thanks a ton!

88a759578d57108136f9042c89b8e0a0?s=140&d=retro CodeCS over 2 years ago

Thank you

525d6cbff10c6022e0004546_261500720 SaN over 2 years ago

Thanks....

5294cac3f10c6076af00039f_320723891 Milen Vasilchev over 2 years ago

Thank you!!!

51c606889c4e9d41050116ba_896668622 Al about 2 years ago

Omg! Thank You This was definately a good fix


5 votes

permalink

the real answer:
def theflyingcircus():
# Start coding here!
answer = "chloe"

if answer == "frog" or answer=="I am an idiot":

    return False

elif answer == "chloe" and 1==1:

    return True

else:

    return False

67 points
5194d06956113ae694002c26_332734110
Submitted by
GeOrGeHaRrIs
about 3 years ago

8 Comments

51704ce322e2530d5f001e78_810040832 Abdul Lamont about 3 years ago

thank you. you can have my bucket

5194d5a06960aa4535002e93_356546339 Abdul jafingle about 3 years ago

def theflyingcircus():
if 1==1 or 2==1+1:
return True
elif 5==3+2:
return True
else:
return True

80029232be72f108f6177d6aab724db1?s=140&d=retro Mim Ahmetaj about 3 years ago

def theflyingcircus():
answer = "Chloe"
if answer == "Chloe" or answer=="I am an idiot":

    return True

elif answer == "frog" and 1==1:

    return False

else:

    return True

E43c53da3e389542a416e90027736a28?s=140&d=retro TheCoder almost 3 years ago

I was wondering why this code was wrong. The console says that there is invalid syntax in line 3 and the "supportive" box is telling me to check my colons. I checked it and it still gives me the same response. Help.

monkey = "The monkey fell"

def theflyingcircus():
if monkey == "The monkey landed" or "The monkey stood up" not "The monkey made it into the pool":

    return False


elif: monkey == "The monkey flew" and "The monkey flew across":


    return False


else: monkey == "The monkey fell":


    return True

611505c458b5a101dd03164c01480d93?s=140&d=retro NinthGG over 2 years ago

I tried all of the above code to answer this problem and this is the first solution that returned a correct answer

F8f5dd85790e7dca591d7bb17dedaecf?s=140&d=retro Yrael about 2 years ago

IndentationError: unindent does not match any outer indentation level wat does this mean????????

5322573b8c1ccc30da005b3f_436806099 Octavian Liviu Dincan about 2 years ago

tks

C88e50a30150046acdb77de9449ee985?s=140&d=retro jack.sankalpgmail.com about 2 years ago

thanks man..!!stucked there but your help ..


5 votes

permalink

Here we go, i can do it, in that way:

def theflyingcircus():
# Written By Renan Zapelini
a = 100
b = 100
c = 200
if a == b:
return True
elif a != b and a > c:
return False
else:
return False

861 points
5225c4e1abf821eb75006519_81510258
Submitted by
Renan Zapelini
almost 3 years ago

4 Comments

Cc8c528e4e53c9d698a2036cf7727e12?s=140&d=retro Rohan N. Shetty over 2 years ago

i loved your code ...

5225c4e1abf821eb75006519_81510258 Renan Zapelini over 2 years ago

Thx. :)

40fcda5848619b6b85f098ac501595b8?s=140&d=retro Александра Михайлова about 2 years ago

Interesting!
You the good fellow:)

5370845e548c3518dd0005d0_348363811 Karthikeyan about 2 years ago

awsome simple and cool!!!!!


3 votes

permalink

Here is the answer:

def the_flying_circus():
if 3>2:
    return True
elif 1>2 and 2>1:
    return False
else:
    return True

165 points
2903da46561fa59a75a2c3fb6760e4ff?s=140&d=retro
Submitted by
faytuu
about 3 years ago

1 Comment

5201146dabf8219bb9004333_770067810 kp_569 almost 3 years ago

Thanks. Mine was too complicated.


3 votes

permalink

the real answer!!!
number = 2

def theflyingcircus():

if number < 3 and number > 1:
return True
elif number == 2:
return True
else:
print " Number is egal to 2"
return True

93 points
513f52fb5f36b3e049000fca_150294805
Submitted by
Adam
about 3 years ago

1 Comment

C86cd2b262b4b5fdf85f59d93ce1000e?s=140&d=retro Jackdavis17 about 3 years ago

no it doesnt!!!!!!!11


3 votes

permalink

Wow that was frustrating. How many people discontinue the course after that?

317 points
D5d5d07e627f5f0c3783d0a713ba5ee2?s=140&d=retro
Submitted by
jab2727
over 2 years ago


2 votes

permalink

Eric,

If we wipe the code out and type it again, can we use tabs only? Is the reason it's best to use 4 spaces idiosyncratic to this editor or just the lesson? This is an argument that apparently has no end, so low or high scope answers are equally good.

Thanks for the lessons!

1660 points
4f78f9272dc51100030250d9_155859613
Submitted by
David Marquardt
about 3 years ago


2 votes

permalink

This work for me.

if 1 < 2 or 3 < 4:
return True
elif 1 > 2:
return False
else:
return False

71 points
B12bc559a465fc48a42edaa9805e310f?s=140&d=retro
Submitted by
Niv Binyamini
almost 3 years ago


2 votes

permalink

Just wanted to share what I wrote this worked for me.

def theflyingcircus():
# Start coding here!
if circus == fun or great:
return True
print "Amazing!"
elif circus != fun:
return False
print "A waste of time."
else:
return False

439 points
3e70737514c41223822d58c4828a238b?s=140&d=retro
Submitted by
shepardc484
over 2 years ago


1 vote

permalink

Hello Eric,
Thanks a lot for the exercises. Very clever of you with the Big if solution. After some errors, I finally got it right. So kids, not just copy and paste!!!

77 points
C762e6db12100b03c836ccb8c96b3a73?s=140&d=retro
Submitted by
francisc@ montero e
over 3 years ago

1 Comment

4fb90c6085cafa000301c847_798121046 CJ about 3 years ago

do you know who your talking to? -_-


1 vote

permalink

Thank you,I’ve solved this problem too.
But then what should I do when I want to change another line to write new codes such as return or elif.
By the way,I'm Chinese,it's really difficult for me to figure out what this course is talking about.And I think it's unnecessary to learn Python,maybe someone can translate it to Chinese.

99 points
C547c88cf13935d3f2c7344e1996a45b?s=140&d=retro
Submitted by
cn007
about 3 years ago

1 Comment

36c11d680dbba7f614e52b579a58850e?s=140&d=retro Brian C. Jackson about 3 years ago

they have created a learning structure for this "general purpose" programming language. it will make more sense as you complete more and more units.


1 vote

permalink

Hopefully this will help for some of you having a problem: My Code is below.

I was getting the same line error's seen in this string, and I found out that it was a spacing error. Move your code 4 spaces on your 1st if line, as you will see in my code. Then move your return line 4 spaces on the second line. The code below is not keeping my spacing used in the exercise, so please use the 4 spaces for each and this should work for you!

I hope this helps you!!

def theflyingcircus():
# Start coding here!
if 8 < 9:
print "I get printed!"
return True
elif 8 > 9 or 7 > 8:
print "I don't get printed."
else:
print "I also don't get printed!"

914 points
50fa6348c4509ec6c8001742_512846259
Submitted by
Falcon212
about 3 years ago

1 Comment

516d8233015e3dd14b000c1a_384730478 Cole Florence about 3 years ago

@Falcon212 Please use markdown to make your code be formatted as code. this will make it easier for others. Thanks.


1 vote

permalink

Thanks

87 points
0dd21b77d3069274108a551a07b77bfb?s=140&d=retro
Submitted by
Max Rohoden
about 3 years ago


1 vote

permalink

okay sorry for that just use this code

def theflyingcircus():
if 1 < 666:
print "Thanks PureAC"
return True
elif 893 > 932 or 32 > 32:
print "asiaskdnasl."
else:
print "asd"

# Start coding here!

and please tab it correctly if your still having problems feel free to ask me at Tyrepickett@gmail.com

492 points
513754d19040d30b87005414_87233238
Submitted by
PureAC
about 3 years ago


1 vote

permalink

this works

def theflyingcircus():
if 1==1 and 5==2*2+1:
return True
elif 5==5:
return True
else:
return True

83 points
9451fa5277ef63624a200a1a0b7fc102?s=140&d=retro
Submitted by
tornadoelliott
about 3 years ago

1 Comment

9451fa5277ef63624a200a1a0b7fc102?s=140&d=retro tornadoelliott about 3 years ago

you need to add spaces before certain lines


1 vote

permalink

else shall be always empty?

338 points
0e1372e413f53077d442d95ab8fc22a9?s=140&d=retro
Submitted by
aehp1113
almost 3 years ago


1 vote

permalink

This is my code. It worked perfectly.

def theflyingcircus():

if number < 3 and number > 1:
    return True
elif number == 2:
    return True
else:
    print " Number is equal to 2"
    return True

240 points
50f5a0c9ac4fb45edb00076b_12988548
Submitted by
Khidr
almost 3 years ago


1 vote

permalink

Thanks for this forum post. The instructions quite often are incredibly vague, you should really do something about it.

125 points
521f88c7548c35cafb000431_761673554
Submitted by
Austra No
over 2 years ago


1 vote

permalink

def the_flying_circus(pythons):
if pythons > 0 < 100:
    return True
elif pythons > 100:
    return not True
else:
    return False

After some trouble with an unexplained syntax error on line 2, (I assumed it was an identation problem), I got this code to pass on the second attempt so use the spacebar instead of relying on enter/tab, since that's what did the trick for me.

406 points
1271fb0cd9ad2f038365c80c20126792?s=140&d=retro
Submitted by
Chris Alexander
over 2 years ago


1 vote

permalink

make it simple...
def theflyingcircus(answer):
if (2>1):
return "True"
elif True and False:
return "False"
else:
return "True"
print theflyingcircus(3)

628 points
523dc3eff10c60805700309f_836193418
Submitted by
mike
over 2 years ago


1 vote

permalink

def theflyingcircus(answer):
if not 9 > 1 or 1 <= 5:
return True
elif 2 < 4:
return 1
else:
return 0

395 points
7507921aaaa921d83506c64b1ab5928b?s=140&d=retro
Submitted by
669167825
over 2 years ago


1 vote

permalink

Thanks this helped so much!

232 points
Ec4914aa78590c881cafaeff9cba6645?s=140&d=retro
Submitted by
Neil Hemnani
over 2 years ago


1 vote

permalink

def theflyingcircus():
# Start coding here!
if 11> 10 or 10==10:
return True
elif 11 < 20:
return False
else:
return True

        #no problem like this

122 points
52d7fe60548c359c28000384_939011019
Submitted by
Tibu
over 2 years ago


1 vote

permalink

i copied this and tried some more but it keeps saying i have an indented block and it points at if
File "python", line 3
if 1 < 2:
^
IndentationError: expected an indented block

44 points
52fcac4f52f863d41f002e0f_396575019
Submitted by
Purpledom
over 2 years ago


1 vote

permalink

Make sure that theflyingcircus() returns True

a = "lets do it"
def theflyingcircus():
if a == "lets do it": # Start coding here!
return True # Don't forget to indent
# the code inside this block!
elif True and False:
return False # Keep going here.
else:
return False# You'll want to add the else statement, too!
--
Don't forget spaces

90 points
534f0b487c82ca2f900001f0_675764341
Submitted by
m_AK47
about 2 years ago


1 vote

permalink

can you guys help me

def theflyingcircus():
if answer > 5 :
return
elif answer < 5 :
return
else:
return True

print greaterlessequal5(4)
print greater
lessequal5(5)
print greaterlessequal_5(6)

234 points
529bcf7d80ff33191f012e76_816736513
Submitted by
Lauren Bunch
about 2 years ago


0 votes

permalink

Eric Weinstein you are one of the best teacher

744 points
523cbfaef10c6024c60002d1_247327759
Submitted by
Nate
almost 3 years ago


0 votes

permalink

After spending at least one hour for this stupid code, I found the simplest way. It should be done as follows:
def theflyingcircus():
if 5>3:

return True
elif 5>10 or 3>5:
return False
else:
return True
Please, don't copy&&paste that might cause an error.
Cheers

55 points
B8ae069f238580e548a34d22da53e004?s=140&d=retro
Submitted by
ElchinIsmayilov
about 2 years ago


0 votes

permalink

In case this helps someone else:
I found that the thing I was missing was to add "return True" or "return False" after my Boolean statements, instead of just "print True". This syntax was used but not explained in the other lessons, which is why I didn't use it on my first attempts..!

def the_flying_circus():
if 3>2:
    return True

676 points
C4b35e3519de92238b7ede61f487aca9?s=140&d=retro
Submitted by
DaveCallaghan
about 2 years ago


-1 votes

permalink

def theflyingcircus():
#Start coding here!
response=5
if True and False:
return False
elif response==5:
return True
else:
return False

This is my answer ,and I get to the next chapter !

62 points
2de781a5f4d1465724b83511666617ee?s=140&d=retro
Submitted by
xrh123
about 3 years ago


-2 votes

permalink

I've tried to copy and paste your code

if 1 < 2:                # This is true...
       return True          # so True will be returned!
elif 1 > 2:
       return False
else:
       return False

and I always get this error:

Traceback (most recent call last):
 File "runner.py", line 105, in compilecode
 File "python", line 4
elif 1 > 2:
   ^
SyntaxError: invalid syntax

How can I fix it?
Thanks in advance.
davide

226 points
B99a76bb90dd52962a273a85d58b7d5b?s=140&d=retro
Submitted by
Davide Linosa
over 3 years ago

9 Comments

2da39560d50c6b3328e2a8459d4339fd?s=140&d=retro Wiss Tsukaza over 3 years ago

  1. You need the function, 2. you need to us at least one comparaison & boolean

Ebb824456ad1dbe8c754f5b89f6d3b4c?s=140&d=retro mkizzi11 over 3 years ago

mine is saying to check the indentation

B4ddfab264e9ccfd415c6c8b89d00b01?s=140&d=retro Jonny Evans over 3 years ago

The whole point is you DONT COPY AND PASTE IDIOTS. READ THE WHOLE THING BEFORE YOU COMMENT STUPID THINGS. PROGRAMMERS ARE NOT STUPID. THEY WILL CLEAVE YOU FROM THE HERD.

539bc500548c353189000a40_869333231 Vlad about 3 years ago

def theflyingcircus():
if 3>2:
return True
elif 1>2 and 2>1:
return False
else:
return True

539bc500548c353189000a40_869333231 Vlad about 3 years ago

put your cursor at the beginning of a line that starts 'elif' or 'else' (it should be indented).
hit the key.
if the cursor goes all the way to the beginning of the line, it was a character. replace it with 4 (four) spaces (i.e., hit 4 times).

C9196fe362df84d56a6f622bb711f18a?s=140&d=retro thewelshgreen about 3 years ago

I agree with you jonny, but try not to be so explosive. Geez.

Fa61c1561eadabd6c20af43f4aa11abf?s=140&d=retro Josh Johnson about 3 years ago

I'm not sure how to copy and paste an idiot...

4f78f9272dc51100030250d9_155859613 David Marquardt about 3 years ago

You cull from a herd. You cleave a molecular bond, or a ham.

516d8233015e3dd14b000c1a_384730478 Cole Florence about 3 years ago

@Davide Linosa Next time please post your questions in the Q&A section. this can be found in the editor at the footer of the page (with the new editor). or if you are using the old editor, it will be at the top.


-2 votes

permalink

Hi,

Here is the code I'm trying but I can't seem to get it right:

def theflyingcircus():
jeff = "animator"
if len(jeff) == 2 + 3:
return True
elif len(jeff) + 2 == 100**0.5 and 2 == 5 - 3:
return True
else:
return False

Thanks in advance!

58 points
512ece2aec9986dd52005fee_547434809
Submitted by
Jeff Treves
about 3 years ago

6 Comments

2903da46561fa59a75a2c3fb6760e4ff?s=140&d=retro faytuu about 3 years ago

dude, it doesn't work....

512ece2aec9986dd52005fee_547434809 Jeff Treves about 3 years ago

Really?

966ea0e0c799543b243749da0f20771f?s=140&d=retro Bruce Linington almost 3 years ago

3+2 is 5.. there's 4 letters in Jeff.
Your elif reads as 4+2 = 6 == 50 and 2 ==2
5 == 50 and 2 == 2
and needs both to be true
6 == 50 #False
So your code reads as:
4 == 5 #False
6 == 50 and 2 == 2 # False
#False

Easy fix to this: if len(jeff) == 2+2

8d0d3d374687fdf5188662c74aec8fc6?s=140&d=retro Sergey Zeygerman over 2 years ago

jeff is the variable name but the actual content of it is the string "animator" which contains 8 letters. It works out.

D3113435f1351717427d6084cad5e7a1?s=140&d=retro maysamfafa77 over 2 years ago

File "python", line 3
jeff = "animator"
^
IndentationError: expected an indented block

D3113435f1351717427d6084cad5e7a1?s=140&d=retro maysamfafa77 over 2 years ago

whats wrong


-2 votes

permalink

My answer:

def the_flying_circus():

a = 100
b = 200
c = 300

of a or b == c:
return True
elif a or b <= c:
return False
else:
return False

Nothing much, but thought I'd give my solution to the problem as well as others have =)

185 points
515d79bef7857f5cd5000d16_852564759
Submitted by
Terje Gjøse
about 3 years ago

3 Comments

55d82ca0e39efe6dc900013e_899919726 nobody can know about 3 years ago

that doenst work !!!!!!!!!!!!!!!!!!!!

516d8233015e3dd14b000c1a_384730478 Cole Florence about 3 years ago

It should work, try using proper indentation.

917515ef3b739485168039ce404c1583?s=140&d=retro imbriacod about 2 years ago

It doesn't work because of the "of" typo in the conditional.


-2 votes

permalink

THE ANSWER IS FART NUGGET

0 points
Default_user
Submitted by
anonymous
about 3 years ago

3 Comments

516d8233015e3dd14b000c1a_384730478 Cole Florence about 3 years ago

Spam is not appreciated here. This is for asking questions and learning.

Default_user anonymous about 3 years ago

ITS NOT SPAM U NOOB

516d8233015e3dd14b000c1a_384730478 Cole Florence about 3 years ago

Spam, as in using the stupid word "Noob" and improper spelling and capitalization is honestly not welcomed.


-3 votes

permalink

I originally used comparisons but got nothing but errors. This is the code I used and it worked. Is this wrong?

answer = "'Tis but a scratch!"

def blackknight1():
if answer == "'Tis but a scratch!":
return True
else: "Tis not a scratch!"

return False

def blackknight2():
if answer == "Go away, or I shall taunt you a second time!":
return True
else: "Goes away"

return False

You're input is greatly appreciated. Thanks in advance!!

125 points
7229567c1d4b1ecaad839f59d41b25b4?s=140&d=retro
Submitted by
Lodog
about 3 years ago

1 Comment

516d8233015e3dd14b000c1a_384730478 Cole Florence about 3 years ago

@Lodog Next time please post your questions in the Q&A section. this can be found in the editor at the footer of the page (with the new editor). or if you are using the old editor, it will be at the top.


-4 votes

permalink

Hi,
What is the best way of "saying" this...?
if 3>2:
return True

elif 1>2 and 2>1:
return False

else:
return True

WHat is the intuition behind returning "True" on the else part? I get the If and Elif part but not the 3rd part.

Thx.

115 points
79a70f6d655ef723fd25d88a0a253bf6?s=140&d=retro
Submitted by
cna892
about 3 years ago

2 Comments

516d8233015e3dd14b000c1a_384730478 Cole Florence about 3 years ago

@cna892 Next time please post your questions in the Q&A section. this can be found in the editor at the footer of the page (with the new editor). or if you are using the old editor, it will be at the top.

5126463f15b5773ae1853bf440c149d4?s=140&d=retro Moncef Bekhtaoui over 2 years ago

nothing is working for me