下面的嵌套if语句导致语法错误,我不知道原因。你知道吗
scores = []
choice = None
while choice != 0:
print(
"""
High Scores
0 - Exit
1- Show Scores
2- Add a Score
3 -Delete a Score
4- Sort Scores
"""
)
#take use input
choice = input("Choice:")
if choice == 0:
print ("Good Bye")
elif choice == 1:
print ("High Scores")
for score in scores:
print(score)
elif choice == 2:
score = input("What score did you get? : ")
scores.append(score)
elif choice == 3:
score =int(input("What score do you want to be removed?:")
if score in scores: <<<------ this line is causing the syntax error
scores.remove(score)
else:
print("The specified score is not in the list.")
elif choice == 4:
score.sort(reverse = True)
print(scores)
else:
print("Sorry, but", choice, "is not valid.")
您需要关闭上一行的
int()
括号。你知道吗相关问题 更多 >
编程相关推荐