【发布时间】:2015-11-04 05:26:39
【问题描述】:
我无法使用用户输入从展开的列表中分离出来。我想我错过了如何使用if 语句来查询特定项目的列表。当用户输入 -999 时,我需要列出请求输入的列表。我还需要从列表中排除 -999。你能帮帮我吗?
print(scoreLst) 可以在我使用它时进行测试,看看它是如何工作的。
scoreLst =[]
score = ()
lst1 = True
print("The list ends when user inputs -999")
scoreLst.append(input("Enter the test score: "))
while lst1 == True:
score1 = scoreLst.append(input("Enter another test score: "))
print(scoreLst)
if score1 != -999:
lst1 == True
else:
scoreLst.remove(-999)
lst1 == False
【问题讨论】:
-
在验证后而不是之前添加到列表中
标签: python python-3.x