Okay, this is werid


#1

So I was just reviewing my "Conditionals and Control Flow" thing (you know, "The Big If") and I submitted the code as you see below. I thought it was pretty good, but when I ran it, it said to me:
File "python", line 9
else
^
SyntaxError: invalid syntax

What's wrong? Please help!

def the_flying_circus():
    if 35 > 67:    # Start coding here!
        print "The flying circus will return"
        
    elif not 68 == 68:
        print "The flying circus may return."
    
    else
        print "The flying circus may return."


#2

else
^
SyntaxError: invalid syntax

expects something after else

see if else lesson


#4

Needs a colon after else so it looks like this. Without the colon after each part of your elif statement, it won't recognize that you have initiated the statment, and will not run correctly and reject it. Look below

def the_flying_circus():

if 35 > 67:
print "The flying circus will return"

elif not 68 == 68:
    print "The flying circus may return."

else:
    print "The flying circus may return."

Another thing you will need to consider is returning in your code. This won't run successfully in the lesson because you have no return values declared. Look back at previous lessons to see what I am talking about.

Implement the return value correctly in the code and then correct the syntax error with your else statement, and you're golden.

Hope this helps!


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.