条件和控制流程 - 大如果

时间:2016-02-08 14:19:02

标签: python

很简单!我在哪里弄错了?我键入5并返回false ...我错过了什么?

# 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!
    else:
        return False
the_flying_circus()
print "Thank you for playing!"

2 个答案:

答案 0 :(得分:3)

raw_input总是返回一个字符串。 “5”不等于5。

答案 1 :(得分:2)

您需要将raw_input转换为int

raw_input()始终返回string

a = int(raw_input())