0
我对Python很新,我正在无限循环中挣扎。看来这应该工作,因为用户输入不是,但它只是杀死该程序。有条件的无限python循环
start = "no"
while start.lower() == "no":
start = input("Are you finished?")
break
我对Python很新,我正在无限循环中挣扎。看来这应该工作,因为用户输入不是,但它只是杀死该程序。有条件的无限python循环
start = "no"
while start.lower() == "no":
start = input("Are you finished?")
break
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
你瞬间打破了while循环,而不关注用户的输入。 – asongtoruin
无论发生什么,你都会从体内循环中突破。 –