The Big If problem


#1

Hello guys, I don't understand this problem. Can anyone help?

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

#2

The console is showing up as:

  File "python", line 10
    print: "False"
         ^
SyntaxError: invalid syntax

#3

The :

print "False"

#4

I've removed the colon. Well spotted, thank you. The code is now:

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

I'm still stuck. Any tips?


#5

Ok, I've sorted it. I've put the correct code below just in case it helps people who are stuck on this problem.

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

#6

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

again its showing error in the line else: invalid syntax


#7

I made a minor mistake as I put true instead of false. Try below code and see if it works:

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

#8

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