Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import time
- moves = ('rock', 'paper', 'scissors')
- winning_moves = {moves[0]: moves[1], moves[1]: moves[2], moves[2]: moves[0]}
- def input_move():
- while True:
- move = input("Enter 1 for rock, 2 for paper, or 3 for scissors: ")
- if move in list('123'):
- return moves[int(move) - 1]
- else:
- print("Invalid input. Try again.")
- victories = 0
- losses = 0
- ties = 0
- messages = "Rock... Paper... Scissors... Says... Shoot!".split()
- while True:
- player_move = input_move()
- print("\nYou played: {}\n".format(player_move))
- for message in messages:
- print(message)
- time.sleep(.5)
- computer_move = random.choice(moves)
- print("\nComputer played: {}\n".format(computer_move))
- if player_move == computer_move:
- print("It's a tie!")
- ties += 1
- elif player_move == winning_moves[computer_move]:
- print("You win!")
- victories += 1
- else:
- print("You lose!")
- losses += 1
- print("Your record is: {} victories, {} losses, {} ties.\n"
- "".format(victories, losses, ties))
Add Comment
Please, Sign In to add comment