Can someone please tell me what this means


#1

Oops, try again. An exception was raised while running your code, see the console window for the error message.

Printed out:

File "python", line 6
elif "1==1" or "1>1" :
^
IndentationError: expected an indented block

this is the code:

# Make sure that the_flying_circus() returns True
def the_flying_circus():
   if 1>1 and 1<1 :    # Start coding here!
        # Don't forget to indent
        # the code inside this block!
   elif  "1==1" or "1>1" :
        # Keep going here.
        # You'll want to add the else statement, too!
        
    else != 1<1 not 1>1 :

#2

else: is a default case that does not take a condition. Also, when comparing numbers, write the expression without quotes.

if 1 == 1 or 1 > 1:

When a string is not empty, it will always evaluate to a True boolean.


#3

It is still giving me the same error message. Now what do I do?


#4

You can either just remove all the comments, or make sure they are indented to match the block level they are at.


#5

I reset the code and put 1==1 and 1<1 in both and still getting the same error message


#6

If you are still stuck, please re-post the code you now have. Recall that although the expectations are spelled out, we are at complete liberty to construct whatever expressions come to mind.

if True or False and True or False:
    return True
elif False <= True and False != True:
    return not False
else:
    return True

Complete nonsense is fine so long as the requisite number of operators are put to use and the function returns True.


#7

This is the code:

# Make sure that the_flying_circus() returns True
def the_flying_circus():
    if  1==1 and 1<1:    # Start coding here!
        # Don't forget to indent
        # the code inside this block!
    elif    1==1 and 1<1:
        # Keep going here.
        # You'll want to add the else statement, too!

this is what prints:

File "python", line 6
elif 1==1 and 1<1:
^
IndentationError: expected an indented block

This is the error message:

Oops, try again. An exception was raised while running your code, see the console window for the error message.

Thanks for the help. If I understood the error message or what printed said I could figure it out myself I just dont understand it


#8

Suggest strip all comments and add an else branch. Give all three branches the line,

return True

#9

Took your advice

Now:
if True: # Start coding here!
# Don't forget to indent
# the code inside this block!
elif True:
# Keep going here.
# You'll want to add the else statement, too!

else True:

Prints:
File "python", line 6
elif True:
^
IndentationError: expected an indented block

Error:
Oops, try again. An exception was raised while running your code, see the console window for the error message.

Maybe delete elif?


#10

Check my example above.

if ____:

elif ____:

else:

#11

It seems hung up on elif no matter what I do

if True or False and True or False:
# return True
elif: False <= True and False != True:
# return not False
else:
#return True


#12

Don't comment the return lines. You need those. Be sure they are indented in each branch.

No colon before the condition. That's the syntax error.


#13

please explain what u mean


#14

The above code has a colon right after elif that does not belong.

The only keyword that gets a colon directly afterward is else: since it does not get a condition. Else is the default action, when one applies. IF and ELIF always get a conditional expression after the key word, and before the colon.

The colon is part of Python block demarcation, not necessarily part of if, but it applies since there are distinct code blocks in the branches.


#15

I changed that but still get the same error message. Thank you for the explantion


#16

What happens when you use the code from above, exactly as written?

https://discuss.codecademy.com/t/can-someone-please-tell-me-what-this-means/83473/6


#17

This is what happens:

def the_flying_circus():
if True or False and True or False:
return True
elif False <= True and False != True:
return not False
else:
return True

File "python", line 5
elif False <= True and False != True:
^
SyntaxError: invalid syntax

Oops, try again. An exception was raised while running your code, see the console window for the error message.


#18

We're getting somewhere, but the expression may not be valid for this version of Python.

>>> False <= True
True
>>> False != True
True
>>>

in Python 3. It should be valid though, since even in Python 2, False casts to 0, and True casts to 1. 0 < 1 => True

You're running Python version 2.7.2. 

 > False <= True
=> True
 > False != True
=> True

Have you got the correct indentation?

>>> def func():
	if True or False and True or False:
		return True
	elif False <= True and False != True:
		return not False
	else:
		return True

	
>>> func()
True
>>>

def func():
    if True or False and True or False:
        return True
    elif False <= True and False != True:
        return not False
    else:
        return True
	
print func()   # True

In the above we use two comparison operators and three logical operators, which satisfies the requirement of the lesson (I believe). Oh, and we return True. That was the other requirement.


#19

Thank you that worked


#20

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