我試圖重擲多個骰子,並且每次都要記住之前的重擲。所以,舉個例子,如果我擲出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)
這是什麼語言?蟒蛇?僞?請添加標籤和/或編寫它的語言。 – feralin 2013-04-07 22:07:10
僅供參考:'如果reroll1 ==「是」或「是」:'不按照您的想法做。你應該嘗試'如果reroll1.lower()==「是」:'而不是。 – DaoWen 2013-04-07 22:11:25
你的問題不是很清楚。所以如果你輸入4,你想要最後一次reroll4掛?或者如果你輸入4,你想要reroll1,2,3,5保持他們以前的卷? – 2013-04-07 22:14:01