The BIG IF


#1

Please can somebody tell me where i went wrong?

def the_flying_circus():
if 2==2 :
return 1
elif 2== 10%5 :
return 0
else:
return -1

Error Message:
File "python", line 2
if 2==2 :
^
IndentationError: expected an indented block


#2

Hi here

IndentationError: expected an indented block

So its a indent problem so here your code with the right indent

def the_flying_circus():
    if 2==2 :
        return 1
    elif 2== 10%5 :
        return 0
    else:
        return -1

#3

Tell me wat to do???
Oops, try again. Make sure to use at least one boolean operator.
Code:
def the_flying_circus():
if 2==2 :
return 1
elif 2== 10%5 :
return 0
else:
return -1
Error:None


#4

It worked. Thank you so much


#5

Hi here

Oops, try again. Make sure to use at least one boolean operator

They aske to put at least one boolean so in your elif you can do it like that

elif 2 == 10 % 5 and 10 % 2 == 0:

And you should return true or false instead of number.


#6

Can some one tell me what I've done wrong?

Make sure that the_flying_circus() returns True

def the_flying_circus():
if answer <10:
return 'Bad'# Start coding here!
# Don't forget to indent
# the code inside this block!
elif answer >10:
return 'Good'
# Keep going here.
# You'll want to add the else statement, too!
else:
return True

It says:
Oops, try again. The following exception was raised when calling the_flying_circus(): NameError: global name 'answer' is not defined


#7

Hi here

Oops, try again. The following exception was raised when calling the_flying_circus(): NameError: global name 'answer' is not defined

The error says that answer isn't defined. You have many way to do that, you could add a raw_input and save it inside answer or you could change answer > 10 to a boolean.

# boolean 

if 2 * 10 == 20 and 10 % 2 == 0:

#raw_input 

answer  = raw_input("please type a number : ")

#8

I have tried both but it still gives me
SyntaxError: invalid syntax: :sweat:


#9

Hi can you post your new code?


#10

Make sure that the_flying_circus() returns True

def the_flying_circus():
if <10 or 'less than 10':
return 'Bad'# Start coding here!
# Don't forget to indent
# the code inside this block!
elif >10:
return 'Good'
# Keep going here.
# You'll want to add the else statement, too!
else:
return True


#11

Please do not post random code ( especially without formatting ) without an explanation.

It doesn't help anyone or further the conversation.


#12

Hi here

if <10 or 'less than 10'

you should remove the 'or less than 10' and just put < and after if remove the < so it should be like that

if 10 < 10:

=====
Then here

elif >10:

You missing Something between if and >

Here how to format your code


#13

will i placed 10 before '< 10' for 'elif' as well as doing what you said for 'if 10 < 10'

Thanks very much :slightly_smiling:


#14

There is no way that a beginner can solve this without getting a head ache. I think Codecademy is lacking pedagogical skills to make these courses. Thanks and good bye, Treehouse next.

ps I just joined.


#15

This one can't be correct because I have just tried it and it come up as "Oops Try Again".

Give me the correct answer for the BIG IF section on code academy.

Thanks.


#16

Here is my code
Go for random instead of creating situation. Make sure if is set to true then elif should be False from all possible solutions see the code

def the_flying_circus():
if 1 < 2 and 2 < 3:
print "Absolute right."
return True# Start coding here!
# Don't forget to indent
# the code inside this block!
elif 1 < 2 and 2 > 3:
print "Sorry wrong."
return False
else:
print "No more answers."
return False
# Keep going here.
# You'll want to add the else statement, too!
Btw Conditionals & Control Flow was damn confusing


#17

hey, its a bit tricky but i got it, take a look

answer = input("enter the number ")
def the_flying_circus():

if  answer < 5 and answer == 6:    
   return True

elif  answer != 6 or 6 > 10 :
    return False

else:
    print "try again"
    return True