在这个程序中,q的验证不起作用。除integer之外的任何其他值都会引发相同的消息“Enter integer values only”。即使输入为“q”,也会发生这种情况。
为什么会这样?解决这个问题的办法是什么?
my_list = []
print("Enter q once done")
while True:
try:
my_list.append(int(input()))
except:
if input == 'q':
break
else:
print("Give integer values only")
continue
print(my_list)