Posted By

p1p1092 on 02/10/12


Tagged

python game dice


Versions (?)

Dice


 / Published in: Python
 

A dice program made in python...

  1. import random
  2.  
  3. def rolldice():
  4. return random.randint(1, 6)
  5.  
  6.  
  7.  
  8. def main():
  9. while True:
  10. stop = input("Roll the dice? y/n: ")
  11. if stop and stop[0].lower() == "n":
  12. break
  13.  
  14.  
  15. # otherwise we roll the dice
  16. dice1 = rolldice()
  17. dice2 = rolldice()
  18.  
  19. print("You rolled %d, %d" %(dice1, dice2))
  20.  
  21. if dice1 == dice2:
  22. print("You rolled a double, you win!!!!")
  23.  
  24. print()

Report this snippet  

You need to login to post a comment.