The BIG If


#1

What is wrong with my code

def the_flying_circus(True):
if 2 < 3 or 4 > 2:
print "You life is over."
elif 6 > 8:
print "Your life is good!"
else:
print "I don't know what to do"


#2

The function doesn't return True.

This function is void. You print some strings, but you do not return boolean variable.

Try something like this:

def the_flying_circus():
    if 2 < 3 or 4 > 2:
        return True
    elif 6 > 8:
       return False
    else:
       return True

#3

Hi there!

If you use the codeblock button (the one with </>), then your code's formatting will be retained.

def the_flying_circus(True):
    if 2 < 3 or 4 > 2:
        print "You life is over."
    elif 6 > 8:
        print "Your life is good!"
    else:
        print "I don't know what to do"

Now... You're passing a variable to the function, which you're choosing to call True, but in your code you don't do anything with it. Your IF structure will also only ever trigger the first condition because 2 is indeed smaller than 3 (and 4 is indeed bigger than 2).


#4

Thank you very much!! Now I understand my problem.


#5

Thanks for everything.


#7

Actually, a new topic thread is preferred. The OP is resolved.