Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- from random import randint
- continueyn = 'y'
- while continueyn == 'y':
- validated = 0
- player = input('rock (r), paper(p) or scissors (s)?')
- if player == 'r' or player == 'p' or player == 's':
- validated = 1
- while validated == 0:
- player = input('Invalid! Please enter \'r\'ock, \'p\'aper, \'s\'cissors!')
- if player == 'r' or player == 'p' or player == 's':
- validated = 1
- print(player, 'vs ', end="", flush=True)
- chosenrand = randint(1,3) #1/r 2/p 3/s
- def cOne():
- print('r')
- if player == 'r':
- print('DRAW!')
- elif player == 'p':
- print('PLAYER WINS!')
- elif player == 's':
- print('COMPUTER WINS!')
- def cTwo():
- print('p')
- if player == 'r':
- print('COMPUTER WINS!')
- elif player == 'p':
- print('DRAW!')
- elif player == 's':
- print('PLAYER WINS!')
- def cThree():
- print('s')
- if player == 'r':
- print('PLAYER WINS!')
- elif player == 'p':
- print('COMPUTER WINS!')
- elif player == 's':
- print('DRAW!')
- if chosenrand == 1:
- cOne()
- elif chosenrand == 2:
- cTwo()
- elif chosenrand == 3:
- cThree()
- continueyn = 'j'
- while (continueyn != 'y') and (continueyn != 'n'):
- continueyn = input('continue? y/n')
- if continueyn == 'n':
- print('goodbye!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement