Python 3.x 如何打破我的循环?
我想让循环将Python 3.x 如何打破我的循环?,python-3.x,loops,Python 3.x,Loops,我想让循环将整数添加到列表中,并在用户点击return时将中断 我如何做到这一点 lstScore = [] count = 0 while count >= 0: count = int(input("Enter a score :")) if count != int: break elif: lstScore.append(int(count)) 这将帮助您,为int转换错误添加异常处理 lstScore = [] c
整数
添加到列表中,并在用户点击return时将中断
我如何做到这一点
lstScore = []
count = 0
while count >= 0:
count = int(input("Enter a score :"))
if count != int:
break
elif:
lstScore.append(int(count))
这将帮助您,为int转换错误添加异常处理
lstScore = []
count = 0
while count >= 0:
try:
temp = input("Enter a score :")
if(temp != ''):
count = int(temp)
else:
break
lstScore.append(int(count))
except ValueError as x:
print("value error")
break
是否希望在用户按下返回键时结束?