【发布时间】:2021-11-21 06:30:40
【问题描述】:
quit_game = "Goodbye, thank you for playing."
while True:
tell_joke = print("Pete, Pete and Repeat went out on the lake in their boat. Pete and Pete fell out. Who is left in the boat? ")
if input() == "REpeat":
print(tell_joke)
break
elif input() == "Quit":
print(quit_game)
break;
每次用户输入“REpeat”时,我都需要循环回到原始的“tell_joke”语句,但是它要么打印新定义的输入,要么读取为无。
【问题讨论】:
-
您需要获取一次输入并在 if 语句中使用它
-
如果你想重复,你不应该“打破”。我猜你想要“继续”。
标签: python python-3.x while-loop