我如何使该计分系统正常工作?

时间:2019-08-27 13:17:47

标签: python python-3.x

我正在尝试为我问过的上一个问答游戏创建一个计分系统。

score = 0

if guess == song_name:

    print("2 points")

    score = score + 2

elif 

    print("1 point")

    score = score + 1

else:

    guess != song_name

    print("0 points")

    score = score + 0

我希望玩家也能在第一次获得正确答案时获得2分,在第二次获得正确答案时获得1分,如果第二次未获得正确答案时获得0分。

1 个答案:

答案 0 :(得分:0)

您需要一个循环以获取答案并尝试进行计数。

score = 0
attempt = 0
guess = ""
while guess != song_name:
    attempt += 1
    print("Enter answer")
    guess = input()
if attempt == 1:
    print("2 points")
    score = score + 2
elif attempt == 2:
    print("1 point")
    score = score + 1
else:
    guess != song_name
    print("0 points")