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

Conditionals & Control Flow Forum

View Course » View Exercise

93 points
2da39560d50c6b3328e2a8459d4339fd?s=140&d=retro
Submitted by
Wiss Tsukaza
over 3 years ago

I cannot find the syntax error - The Big If

I'm trying to finish the last exercice "The Big If" and cannot find my syntax error.
My code is the following :

answer == "The flying circus doesn't fly"

def the_flying_circus():
    if answer == "The flying circus is a plane": 
        Return False
    elif answer == "The flying circus doesn't fly": 
        Return True
    else : 
        Return False

I don't get it. It says to double check my colons.

The exact error message is :

Traceback (most recent call last):
  File "runner.py", line 105, in compilecode
  File "python", line 5
    Return False
               ^
SyntaxError: invalid syntax
Double check your colons!
Oops, try again. 

Now, I read it's at the line 5, the elif line, but I really don't see why.


5 votes

permalink

I've improvised my answer to this, worked fine, although it's not related to def, but it's good enough to pass based on the criteria:

def theflyingcircus():
#Start coding here!
answer = "The flying circus doesn't fly"

def theflyingcircus():
if answer == 0 > 1 and 1 > 2:
return False
elif answer == 1 == 1:
return True
else:

return False

P:s: Don't copy & paste, I suggest you type it

1099 points
513c95d77b9c569075006ff2_278194746
Submitted by
Ash Alwi
over 3 years ago


1 vote

permalink

Solved !

First of all, everybody should read this :
The Big If

Then "Return" should be "return", and lastly, the first (answer == "The flying circus doesn't fly") should contain only one "=".

Good luck and thank you Eric Weinstein !

93 points
2da39560d50c6b3328e2a8459d4339fd?s=140&d=retro
Submitted by
Wiss Tsukaza
over 3 years ago

1 Comment

3e481ee7410afd41cb7d2291379ee04a?s=140&d=retro tea man over 3 years ago

@wiss tsukaza. i did al the things you mentioned here. and still wont get a response to my code.... also no errors....why is this happening with all of my code. no errors no responses. ducks.


0 votes

permalink

thank yuo

430 points
50edc2098fd8395bba00043e_175856524
Submitted by
christhorn2000
over 3 years ago


0 votes

permalink

#mine is like this
def theflyingcircus():
#Start coding here!
answer == "The flying circus doesn't fly"

def theflyingcircus():
if answer == "The flying circus is a plane":
return False
elif answer == "The flying circus doesn't fly":
return True
elif answer == "The flying circus doesn't fly" or "The flying circus is a plane":
return True

else :
return False

465 points
511070b7efa2f887f300079d_752428391
Submitted by
papercutting
over 3 years ago

2 Comments

511070b7efa2f887f300079d_752428391 papercutting over 3 years ago

It works right.

572347915917ec615700053d_397807894 Nikita Yerenkov-Scott over 3 years ago

This is what it says with me: "Traceback (most&nbsprecent&nbspcall&nbsplast):
&nbspFile "runner.py",&nbspline&nbsp123,&nbspin&nbspcompilecode
&nbspFile "python",&nbspline&nbsp5
&nbspreturn&nbspFalse
^
IndentationError:&nbspexpected&nbspan&nbspindented&nbspblock
Oops, try again.
Double check your indentation!".


0 votes

permalink

My attempt at this one.

answer = 10

def theflyingcircus():
if answer == 5 + 20 and 5 + 40:
return False
elif answer == 5 + 6:
return False
elif answer == 10**1:
return True
else:
return False

135 points
51823e6038eba1860d002a57_911730292
Submitted by
Shaun Crawford
over 3 years ago