我用python做的测验赢了';行不通

我用python做的测验赢了';行不通,python,Python,我最近在我的计算机科学课上做了一个小测验,但由于某些原因它不起作用,我对编程是新手,我想知道你是否能帮助我,我知道它会很简单,但正如我所说的,我对这是新手。我只抄了8个问题中的4个,但出于某种原因,它忽略了IF语句,直接转到else语句。代码如下: score=0 print("Welcome the the general knowledge quiz") your_name = input("What is your name?: ") input("Press Enter to Star

我最近在我的计算机科学课上做了一个小测验,但由于某些原因它不起作用,我对编程是新手,我想知道你是否能帮助我,我知道它会很简单,但正如我所说的,我对这是新手。我只抄了8个问题中的4个,但出于某种原因,它忽略了IF语句,直接转到else语句。代码如下:

score=0
print("Welcome the the general knowledge quiz")
your_name = input("What is your name?: ")

input("Press Enter to Start the Quiz!")

print("1) Who presents Pointless?")
answer = input()
if answer == ["Alexander Armstong", "alexander armstrong", "ALEXANDER  
ARMSTRONG"]:
    print("Well done", your_name)
    score = score+1
else:
    print("Sorry, the answer was Alexander Armstrong")
print("Your score is", score)


print("2) Who presents I'm a celeb, get me out of here?")
answer = input()
if answer == ["Ant and Dec", "ant and dec", "ANT AND DEC", "Ant And Dec"]:
    print("Well done", your_name)
    score = score+1
else:
    print("Sorry, the answer was Ant and Dec")
print("Your score is", score)


print("3) What is the capital of England?")
answer = input()
if answer == ["London", "london", "LONDON"]:
    print("Well done", your_name)
    score = score+1
else:
    print("Sorry, the answer was London")
print("Your score is", score)


print("4) Who lives on the White house right now?")
answer = input()
if answer == ["Obama", "obama", "Barack Obama", "barack obama"]:
    print("Well done", your_name)
    score = score+1
else:
    print("Sorry, the answer was Barack Obama")
print("Your score is", score)

语法突出显示中有一个提示:您缺少一个

阿姆斯特朗之后没有

answer = input()
if answer == ["Alexander Armstong", "alexander armstrong", "ALEXANDER  
ARMSTRONG ):
撇开引号不谈,这个if语句总是失败的
input()
总是返回一个字符串,但您要检查它是否等于一个列表,这永远不会是真的。如果在中将
==
替换为
,它将实现您所期望的功能


此外,你应该考虑使用<代码> .Load()/Case>将答案变成小写,然后你只有一个值来检查。

欢迎常识问答。你叫什么名字?杰克按Enter开始问答!1) 谁提出了毫无意义的建议?Alexander Armstrong抱歉,答案是Alexander Armstrong你的分数是0 2)谁介绍我是名人,带我离开这里?这是我从你建议的更改中得到的(它们是要排成一行的,但我不允许)。那是因为你在列表的第一个位置拼写错误了
Armstrong
。这样的打字很容易,这就是为什么我建议用户输入小写,然后只对照“alexander armstrong”的小写版本进行检查。这样的话,你就只有一个字符串可以搞乱,而不是三个,而且它还可以处理像“亚历山大·阿姆斯特朗”这样的事情。非常感谢你,最后一个问题的答案是数字,它不起作用。打印(“7)女王多大岁数?”)答案=输入()答案=int(答案)如果答案==[“90”]:打印(“做得好”,你的名字)分数=分数+1其他:打印(“对不起,答案是90”)打印(“你的分数是”,分数)它做完全相同的事情
answer = input()
if answer == ["Alexander Armstong", "alexander armstrong", "ALEXANDER  
ARMSTRONG ):