我对python很新,我正在努力进行无限循环。似乎这应该工作,因为用户输入不是,但它只是杀死程序。
start = "no"
while start.lower() == "no":
start = input("Are you finished?")
break
答案 0 :(得分:2)
break
无条件地中止while
循环。删除它,如下所示:
start = "no"
while start.lower() == "no":
start = input("Are you finished?")
或者,如果您想使用break
,请将其设为条件:
while True:
start = input("Are you finished?")
if start.lower() != "no":
break