【发布时间】:2015-06-16 11:45:58
【问题描述】:
当用户的输入为
while True:
try:
x = input("how many times do you want to flip the coin?: ")
if int(x) <= 0 or x.lower() == "stop":
break
x = int(x)
coinFlip(x)
except ValueError:
print ()
print ("Please read the instructions carefully and try one more time! :)")
print ()
我得到错误:
if int(x) <= 0 or str(x).lower() == "stop":
ValueError: invalid literal for int() with base 10: 'stop'
【问题讨论】:
标签: python validation debugging python-3.x optimization