Python中的循环中的循环
我想知道是否可以在python中,在循环B中重新启动循环A。例如:Python中的循环中的循环,python,loops,Python,Loops,我想知道是否可以在python中,在循环B中重新启动循环A。例如: while True: #Loop A while True: #Loop B ans = int("Question") if ans == "y": print("Something") else: ??? 跟???表示返回并重复循环A的代码。 求你了,我真的需要这个答案。对于那些已经或将要回答的人,谢
while True: #Loop A
while True: #Loop B
ans = int("Question")
if ans == "y":
print("Something")
else:
???
跟???表示返回并重复循环A的代码。
求你了,我真的需要这个答案。对于那些已经或将要回答的人,谢谢 在python中,可以使用
break
退出所处的循环
while True: #Loop A
while True: #Loop B
ans = int("Question")
if ans == "y":
print("Something")
else:
break
你的意思是
break
?为什么不干脆break
?可能的重复-问题本身由break
回答,但如果涉及其他逻辑,“去重复一次”与“停止电流回路”不是一回事,非常感谢!