The Big if


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
I am stuck on the big if, on line 8 (look below)

<In what way does your code behave incorrectly? Include ALL error messages.>
The error message is “invalid syntax”.

<What do you expect to happen instead?>

```python

def the_flying_circus():
if 2>1 and 3>=2 or True: # Start coding here!
# Don’t forget to indent
# the code inside this block!
print “True”
return True
elif not True and 3==3 or 3!=4 or 3<=3:
# Keep going here.
# You’ll want to add the else statement, too!
print"False"
return True
else:
print True
return True

<do not remove the three backticks above>

#2

First off, let’s remove all the print statements for now, and just review the structure of an if statement:

def ___():
    if ___:

    elif ___:

    else:

The objective of the program is to return True. We can do this any way we wish, so long as one of the branches returns the expected value.

if "b" in "milk":
    return True
elif 1 ** 2 == 0:
    return True
else:
    return True

As we can see, the program will return True, but by default since the else statement is executed. It’s all silliness, but still works. Have fun with this exercise and play around with it. Don’t bury yourself in anything complicated unless you are up to the challenge of solving any problems that arise.


#3

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