【发布时间】:2020-05-29 06:29:21
【问题描述】:
我想知道,我该怎么做才能使即使答案是大写的,它仍然会标记分数?我是python新用户...
colleges = ["MIT", "UAB", "Harvard", "UA", "Standford"]
votes = [0, 0, 0, 0, 0]
Q1 = input("What is important in your future?\na)Invent something important\nb)Helping other people\nc)Know everything\nd)A job that I love\ne)Make the world better\n")
if (Q1 == "a"):
votes[0] = votes[0]+1
elif (Q1 == "b"):
votes[1] = votes[1]+1
elif (Q1 == "c"):
votes[2] = votes[2]+1
elif (Q1 == "d"):
votes[3] = votes[3]+1
elif (Q1 == "e"):
votes[4] == votes[4]+1
【问题讨论】:
-
使用
Q1.lower() -
if Q1.lower() == 'a':其他情况类似 -
您还应该检查“以上都不是”并提示用户重试。
标签: python