Advertisement
DamonShekari

Northwestern Mini-Project - Dice Roll

May 23rd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. #This program took me a bit. Through a lot of research and asking questions,
  2. #i learned that putting the statement in a while True loop allowed the program
  3. #to repeat the question and continue letting the user ask to roll a dice
  4.  
  5. import random
  6.  
  7. while True:
  8.     print()
  9.     userInput = input('Roll dice? (y/n) \n >')
  10.     if userInput == 'y':
  11.         foo = ['1', '2', '3', '4', '5', '6']
  12.         print(random.choice(foo))
  13.     elif userInput == 'n':
  14.         print('No number shall be rolled.')
  15.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement