Big If Indentation Error


#1



I am receiving the following error message.
File "python", line 5
elif 10 > 11:
^
IndentationError: expected an indented block

When I adjust the indent (which does not look off) by hitting the tab key once, I receive another error message.

File "python", line 5
elif 10 > 11:
^
SyntaxError: invalid syntax


I think the code is correct. Can someone tell me what I am doing wrong? Thank you.


# Make sure that the_flying_circus() returns True
def the_flying_circus():
    if 1 == 1 and 10 !=11:    # Start coding here!
        # return True
    elif 10 > 11: 
        # return True
    else
        # return False
# print the_flying_circus()


#2

Try removing the comment symbol # from the return lines.


#3

Thanks, but that did not help. The error is on the line that starts with elif.


#4

The error is reacted to on that line, but may in the line above it. That is where parsing stopped because the interpreter encountered something it did not expect. That means the error is before that point. Did you uncomment the return statements?


#5

Yes. I tried it again and only removed the #.

Make sure that the_flying_circus() returns True

def the_flying_circus():
if 1 == 1 and 10 != 11: # Start coding here!
return True
elif 10 > 11:
return True
else
return False

print the_flying_circus()

The error now reads:
File "python", line 7
else
^
SyntaxError: invalid syntax

This is referring to the "else" line.


#6

I got it. I added ":" after "else". Thanks for your help.


#7

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