为什么' if得分> 3:'这个脚本的一部分不起作用?

时间:2016-06-11 22:36:55

标签: python

我想要打印这个脚本"做得好"如果玩家得分大于3,则为5次,但不起作用。请帮忙!

score = 0
print "This quiz is based around the video game series, Metal Gear."
person = raw_input("Before we start, please enter your name: ")
print("Lets begin", person)
print "A. 1995"
print "B. 2000"
print "C. 2002"
print "D. 1999"
Q1 = raw_input ("What year did the Outer Heaven Revolt take place?")
if Q1 == "A" or Q1 == "a":
        print "You are correct!"
        score = score+1
else:
    print "Wrong! The correct answer was A"
print "A. Liquid Ocelot"
print "B. Liquid Snake"
print "C. Big Boss"
print "D. Colonel Volgin"
Q2 = raw_input ("Who is the main antagonist in Metal Gear Solid 1?")
if Q2 == "B" or Q2 == "b":
    print "You are correct!"
    score = score+1
else:
    print "Wrong! the correct answer was B"
print "A. Raiden"
print "B. Venom Snake"
print "C. Vamp"
print "D. Sunny"
Q3 = raw_input ("Who is the character with a cyborg body?")
if Q3 == "A" or Q3 == "a":
    print "You are correct!"
    score = score+1
else:
    print "Wrong! the correct answer was A"

print ("Thank you for playing", person)
print ("You have a score of", score)
if score > 3:
    print "Well done / Well done / Well done / Well done / Well done"

1 个答案:

答案 0 :(得分:4)

任何玩测验的人都只能达到3分。它永远不会大于 3,所以你的if score > 3:测试永远不会成真。只有score设置为4或更高时,该测试才会通过。

更改测试以使用等号,因此==

if score == 3:
    print "Well done / Well done / Well done / Well done / Well done"