我是python的新手,我需要一些帮助。我只需要知道如何循环这段代码,以便在它说“请再试一次......”之后它会进入“你想滚动还是坚持”。提前谢谢。
Roll = input("Do you want to Roll or Stick?")
if Roll in ("Roll" , "roll"):
print("Your new numbers are," , +number10 , +number20 , +number30 , +number40 , +number50)
if Roll in ("Stick" , "stick"):
print("Your numbers are," , +number1 , +number2 , +number3 , +number4 , +number5)
else:
print("Please try again.")
答案 0 :(得分:1)
您可以使用while
循环包装代码:
while True:
Roll = input("Do you want to Roll or Stick?")
if Roll.lower() == 'exit':
break
...
else:
print("Please try again. Type 'exit' to exit.")