The Big If


#1

Help me!My code shows an Error!!
Will really appreciate it.Thank you

def the_flying_circus():
    if 2>=2:
      return True
    elif not False or 1==1:
        return True
        else:
          return True
print the_flying_circus()

#2

else should have the same indent(ion) level as elif, since you want to execute else when if and elif are false.


#3

where did i make my mistake?


#4

here:

else:

the indent/spacing is wrong


#5

How about now?

def the_flying_circus():
if 2>=2:
return True
elif not False or 1==1:
return False
else:
return True
print the_flying_circus()


#6

you only needed to change the indent of else , not all other lines.


#7

2>=2: shows error

File "python", line 3
return True
^
IndentationError: expected an indented block


#8

lets go back to your old code:

def the_flying_circus():
    if 2>=2:
      return True
    elif not False or 1==1:
        return True
        else:
          return True
print the_flying_circus()

you only need to change the indent of one line, which is else:

else needs to come after elif, thus it should have the same indention/spacing level


#9

Now line 6 shows an Error


#10

because you still need to change the indention of that line. Remember how we build an if/elif/else clause?

if True:
   print True
elif False:
   print False
else:
   print "impossilbe"

see how if/elif/else have the same indention level? this should also be in your code


Not again
#11

Thanks!! I did it!!!
You were a great Help!!


#12