複数のサイコロを再ロールしようとしていますが、毎回前回の再ロールも覚えています。たとえば、サイコロを 5 個振って 1,2,3,4,5 が出るとします。どのダイスを再ロールするかを尋ねます-1、3、4、そして3、2、5、3、5のようなものを取得します。しかし、ループで尋ねると、以前の新しいロールが上書きされ、最後のロールのみが返されます。ループを実行するときに、新しく見つかった数値を保存するにはどうすればよいですか?
reroll1 = input("Would you like to reroll? Yes or No: ")
if reroll1 == "Yes" or "yes":
count = 0
times = int(input("How many die would you like to reroll? "))
while count < times:
whichreroll = input("Reroll die: ")
if whichreroll == "1":
reroll1 = random.randint(1,6)
else:
reroll1 = die1
if whichreroll == "2":
reroll2 = random.randint(1,6)
else:
reroll2 = die2
if whichreroll == "3":
reroll3 = random.randint(1,6)
else:
reroll3 = die3
if whichreroll == "4":
reroll4 = random.randint(1,6)
else:
reroll4 = die4
if whichreroll == "5":
reroll5 = random.randint(1,6)
else:
reroll5 = die5
newset = [reroll1, reroll2, reroll3,reroll4,reroll5]
count += 1
print(newset)