import tkinter
import random
def rollDice():
x=random.randint(1,6)
total=0
if x == 1:
total+=1
....
print(total)
我想将.rollDice
中的每个号码添加到total
并存储到dispatcherServlet-servlet.xml
,最大值为50.我该怎么做?
答案 0 :(得分:0)
正如@PaulRooney所说,我不确定tkinter
与此有什么关系。根据我的理解,你想掷骰子直到你的total
达到或超过50 ..所以这是我对此的看法:
from random import randint
def rollDice():
return randint(1,6)
total = 0
while total < 50:
new_roll = rollDice()
total += new_roll
print('You rolled a {}. The new total is {}'.format(new_roll, total))
# You rolled a 3. The new total is 3
# You rolled a 3. The new total is 6
# You rolled a 4. The new total is 10
# You rolled a 6. The new total is 16
# You rolled a 2. The new total is 18
# You rolled a 1. The new total is 19
# You rolled a 5. The new total is 24
# You rolled a 5. The new total is 29
# You rolled a 4. The new total is 33
# You rolled a 5. The new total is 38
# You rolled a 2. The new total is 40
# You rolled a 3. The new total is 43
# You rolled a 4. The new total is 47
# You rolled a 6. The new total is 53