【发布时间】:2019-03-05 11:17:12
【问题描述】:
这是我写的试图回答标题中问题的代码:
import random
print("Well, hello there.")
while True:
a = random.randint(1,6)
sum = 0
if(a==1): #If a one is indeed rolled, it just shows rolled a 1 and 'Pigs out' and makes the score equal to 0(player score that is) and is a sort of a GameOver
print("Pigged out!")
break #To get out of the loop
else:
while(sum<=20):
sum += a
print(sum)
程序应将分数保持到 20(或更多)并显示它。它本质上代表“猪”的单圈。我无法弄清楚我哪里出了问题?任何建议都会有所帮助。
示例输出示例:
-rolled a 6
-rolled a 6
-rolled a 5
-rolled a 6
-Turn score is 23
【问题讨论】:
标签: python python-3.x probability dice