Introduction to Control Flow

← Forum
93 pts

Wiss Tsukaza

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.

  • 1019 pts

    Ash Alwi

    4 votes

    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

  • 93 pts

    Wiss Tsukaza

    2 votes

    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 !

    • tea man about 1 year 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.
  • 131 pts

    Shaun Crawford

    1 votes

    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

  • 430 pts

    christhorn2000

    0 votes

    thank yuo

  • 465 pts

    papercutting

    0 votes

    #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

    • papercutting about 1 year ago
      It works right.
    • Nikita Yerenkov-Scott about 1 year 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!".

Sign in to post to the forum.

Sign in