如何在python中找到骰子掷骰程序的最小值和最大值

时间:2018-12-28 23:33:03

标签: python

import random
print(' \t Welcome rolling dice game\n ')


while True :
 input(' Press any key to roll')
 roll=random.randint(1,6)
 print(roll)

 stop= input( ' you want to roll. again ? \n if yes then enter y \n if not then enter n\n ')
 if stop=='y':
   continue
 elif stop=='n':
   break


print(' Thanks for Playing:')

1 个答案:

答案 0 :(得分:2)

尝试:

min = 6
max = 0
while True :
   input(' Press any key to roll')
   roll=random.randint(1,6)
   print(roll)

   if roll>max:
      max = roll
   if roll<min:
      min = roll