gpt4 book ai didi

python - 没有跳出 while 循环

转载 作者:太空宇宙 更新时间:2023-11-04 06:47:27 25 4
gpt4 key购买 nike

<分区>

我编写了一些代码,可以掷两个骰子并询问用户多少次。之后它会询问用户是否要再次玩。由于某种原因,它没有在应该跳出的 while 循环中跳出。

代码如下:

import random
again = True
rolls = 0
while again == True:
rolls = float(raw_input("How many times would you like the dice to roll?"))
while rolls >= 1:
dice1 = random.randint(1,6)
dice2 = random.randint(1,6)
print dice1 , dice2
rolls = rolls - 1
again = raw_input("Would you like to play again?")
if again == "Yes" or "Y" or "yes" or "y":
again = True
else:
again = False

谁能帮帮我

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com