Advertisement
KaySawbridge

2 Dice Random Roll Function

Jul 16th, 2020
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. #2 dice - random throw
  2. import random # import outside the loop
  3. def dice_throw():
  4.  
  5.     rolls = int(input("How many times would you like to roll the dice? "))
  6.  
  7.     while rolls > 0:
  8.         diceone = random.randint(1,6) # these inside the while loop
  9.         dicetwo = random.randint(1,6) # so you get a new roll each time
  10.         print("First dice = ",diceone)
  11.         print("Second dice = ",dicetwo)
  12.         rolls = rolls -1
  13.         print ("Number of rolls left = ",rolls)
  14.  
  15. dice_throw()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement