我遇到一些麻烦打破这些循环:摆脱循环?
done = False
while not done:
while True:
print("Hello driver. You are travelling at 100km/h. Please enter the current time:")
starttime = input("")
try:
stime = int(starttime)
break
except ValueError:
print("Please enter a number!")
x = len(starttime)
while True:
if x < 4:
print("Your input time is smaller than 4-digits. Please enter a proper time.")
break
if x > 4:
print("Your input time is greater than 4-digits. Please enter a proper time.")
break
else:
break
它承认数目是否< 4> 4,但即使输入的数字是4位数返回到开始该程序而不是继续下一段代码,这是不是在这里。
您在哪里更改为True? – 2014-10-29 01:53:16
尝试: stime = int(starttime)#你的意思是starttime = int(starttime)。 – Crispy 2014-10-29 01:57:57