【发布时间】:2019-04-06 11:02:29
【问题描述】:
所以我这里有这段代码:
count = 1
if count < 5:
print ("If 5 rounds have passed, enter any other key: ")
nextr = str(input("Do you want to continue to the next round?(1)" + "\n"))
if nextr in ("1", "(1)"):
count += 1
continue
while count == 5:
break
我想知道:如果不每次都恢复到 1,我怎么能做这个计数控制循环。我希望程序通过一次游戏,询问用户是否要继续,然后在中断之前再通过 4 次,然后显示最终分数。非常感谢任何帮助!
【问题讨论】:
-
你完全搞乱了循环和条件语句。想想这是在做什么:
while count == 5: break. -
你的意思是
if count < 5:转换为while count < 5:? -
输入已经是字符串,不需要解析
str(input[...]
标签: python count iteration increment