我正在做一项需要进行测验的作业。到目前为止,这是我的代码的一部分。
answer = input("Your answer: ")
guessesTaken = 0
points = 0
if answer == 'Call Of Duty' or answer == 'Call of duty' or answer == 'Call of duty' or answer == 'a)' or answer == 'call of duty' or answer == 'a':
print("You are correct!")
points = points + 2
print("You scored two points!")
else:
guessesTaken = guessesTaken + 1
print("Incorrect!")
print("You have", guessesTaken, "guess remaining!")
answerb = input("Your answer: ")
if answerb == 'Call Of Duty' or answerb == 'Call of duty' or answerb == 'Call of duty' or answerb == 'a)' or answerb == 'call of duty' or answerb == 'a':
points = points + 1
print("You scored one point!")
如果 answerb 出现错误,我会收到错误消息。我无法弄清楚为什么会收到此错误。这部分代码旨在为您答对的每个问题评分。计分制度如下,第一次答对2分,第二次答对1分,第三次答错0分。我认为使用 answerb 会让我再试一次并给 1 分。如果你能解释一下,我以后不会再这样做了。:)