Advertisement
Guest User

Dice

a guest
Nov 25th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. import random
  2.  
  3. def main():
  4.     global userIn
  5.     userIn = input("Enter how many sides you want on your dice:  ")
  6.     userint()
  7.     num = random.randrange(0, userInt)
  8.     compStr = str(num)
  9.     print("The computer chose " + compStr)
  10.     restart()
  11.    
  12. def userint()
  13.     try:
  14.         global userInt
  15.         userInt = int(userIn)
  16.     except ValueError:
  17.         print("That's not a number!")
  18.         main()
  19. def restart():
  20.     again = input("Play Again? Yes/No: ")
  21.     againLower = again.lower()
  22.     if againLower == "y" or againLower == "yes":
  23.         main()
  24.     elif againLower == "n" or againLower == "no":
  25.         print("Goodbye!")
  26.         quit()
  27.     else:
  28.         print("That's an invalid input")
  29.         restart()
  30.    
  31. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement