Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. #!/usr/bin/python3
  2.  
  3. from random import randint
  4.  
  5. continueyn = 'y'
  6.  
  7. while continueyn == 'y':
  8.  
  9. validated = 0
  10.  
  11. player = input('rock (r), paper(p) or scissors (s)?')
  12. if player == 'r' or player == 'p' or player == 's':
  13. validated = 1
  14.  
  15. while validated == 0:
  16. player = input('Invalid! Please enter \'r\'ock, \'p\'aper, \'s\'cissors!')
  17. if player == 'r' or player == 'p' or player == 's':
  18. validated = 1
  19.  
  20.  
  21. print(player, 'vs ', end="", flush=True)
  22.  
  23. chosenrand = randint(1,3) #1/r 2/p 3/s
  24.  
  25. def cOne():
  26. print('r')
  27. if player == 'r':
  28. print('DRAW!')
  29. elif player == 'p':
  30. print('PLAYER WINS!')
  31. elif player == 's':
  32. print('COMPUTER WINS!')
  33.  
  34. def cTwo():
  35. print('p')
  36. if player == 'r':
  37. print('COMPUTER WINS!')
  38. elif player == 'p':
  39. print('DRAW!')
  40. elif player == 's':
  41. print('PLAYER WINS!')
  42.  
  43. def cThree():
  44. print('s')
  45. if player == 'r':
  46. print('PLAYER WINS!')
  47. elif player == 'p':
  48. print('COMPUTER WINS!')
  49. elif player == 's':
  50. print('DRAW!')
  51.  
  52. if chosenrand == 1:
  53. cOne()
  54. elif chosenrand == 2:
  55. cTwo()
  56. elif chosenrand == 3:
  57. cThree()
  58.  
  59. continueyn = 'j'
  60.  
  61. while (continueyn != 'y') and (continueyn != 'n'):
  62. continueyn = input('continue? y/n')
  63.  
  64. if continueyn == 'n':
  65. print('goodbye!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement