Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def numberToName(number):
- if number == 1:
- choice = 'rock'
- elif number == 2:
- choice = 'paper'
- else:
- choice = 'scissors'
- return choice
- def rockPaperScissors():
- player1 = numberToName(int(input()))
- player2 = numberToName(random.randint(1, 3))
- if player1 == 'rock' and player2 == 'rock':
- print("Player1 choose rock")
- print("Player2 choose rock")
- print('Player1 and Player2 tied')
- elif player1 == 'paper' and player2 == 'paper':
- print("Player1 choose paper")
- print("Player2 choose paper")
- print('Player1 and Player2 tied')
- elif player1 == 'scissors' and player2 == 'scissors':
- print("Player1 choose scissors")
- print("Player2 choose scissors")
- print('Player1 and Player2 tied')
- elif player1 == 'rock' and player2 == 'paper':
- print("Player1 choose rock")
- print("Player2 choose paper")
- print("Player2 wins")
- return "Player2 wins"
- elif player1 == 'rock' and player2 == 'scissors':
- print("Player1 choose rock")
- print("Player2 choose scissors")
- print('Player1 wins')
- return 'Player1 wins'
- elif player1 == 'scissors' and player2 == 'paper':
- print("Player1 choose scissors")
- print("Player2 choose paper")
- print('Player1 wins')
- return 'Player1 wins'
- elif player1 == 'scissors' and player2 == 'rock':
- print("Player1 choose scissors")
- print("Player2 choose rock")
- print("Player2 wins")
- return "Player2 wins"
- elif player1 == 'paper' and player2 == 'rock':
- print("Player1 choose paper")
- print("Player2 choose rock")
- print('Player1 wins')
- return "Player1 wins"
- elif player1 == 'paper' and player2 == 'scissors':
- print("Player1 choose paper")
- print("Player2 choose scissors")
- print("Player2 wins")
- return "Player2 wins"
- def countLetters(word, char):
- W = 0
- L = 0
- while W <= 2:
- if rockPaperScissors() != 'Player1 wins':
- continue
- W = W + word
- if W == 2:
- print('Player1 wins the whole match with', W, 'out of 3.')
- elif rockPaperScissors() != 'Player2 wins':
- continue
- L = L + word
- if L == 2:
- print('Player2 wins the whole match with', L, 'out of 3.')
- break
- if __name__ == '__main__':
- userInput = 0
- while userInput != -1:
- print("\nPlease select one of the menu options")
- print(" 1. Start game of rock, paper, scissors")
- print("-1. to exit the program.")
- userInput = input()
- if (userInput == '1'):
- print('\nStarting Game... Input 1 for rock, 2 for paper or 3 for scissor.\n')
- elif userInput == '-1':
- break
- while True:
- value = countLetters(1, char='')
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement