2016-06-11 7 views
-4

プレイヤーのスコアが3を超えていても動作していない場合、このスクリプトで「うまくやった」と5回印刷します。助けてください!しか3のスコアに到達することができ、あなたのクイズをプレイこのスクリプトの 'スコア> 3:'の部分がうまくいかないのはなぜですか?

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" 
+4

あなたのプログラムがしか0と3の間のスコアを生成するが、それは3 –

+1

ドン」より** **高ければ、あなたがテスト何かが動作していないと私に教えてください。起こると予想されることを教えてください。代わりに何が起こるか教えてください。例外がある場合に得られる完全なトレースバックを含めます。 –

答えて

4

誰もがそれはとてもあなたのif score > 3:テストが真なることはありません、 3より大きくすることはできません。 scoreが4以上に設定されている場合、そのテストは合格になります。

変更し、使用するテストではなく等しいので、==

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

非公式には申し訳ありませんが、これはこの最高のサイト<3に初めて投稿しました。今は解決しましたので、助けてくれてありがとうございます! = D –

関連する問題