Home Ask Login Register

Developers Planet

Your answer is one click away!

Giles Bowman February 2016

Conditionals & Control Flow - The Big If

Very simple! Where did I get this wrong? I typed 5 and it returned false... What did I miss?

# Make sure that the_flying_circus() returns True
def the_flying_circus():
    print "Press number 5 otherwise it will return false"
    a = raw_input()
    if a == 5:
        print "Correct!"
        return True
        # Start coding here!
        # Don't forget to indent
        # the code inside this block!
    elif a != 5:
        print "Wrong"
        return False
        # Keep going here.
        # You'll want to add the else statement, too!
        return False
print "Thank you for playing!"


Daniel Roseman February 2016

raw_input always returns a string. "5" does not equal 5.

cyberbemon February 2016

you need to convert your raw_input to an int.

raw_input() always returns a string

do a = int(raw_input())

Post Status

Asked in February 2016
Viewed 3,763 times
Voted 7
Answered 2 times


Leave an answer

Quote of the day: live life