Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import random
- import sys
- def game():
- options = ["rock","paper","scissors"]
- computer_choice = random.choice(options)
- player_choice = (raw_input('\nPlease enter your choice '
- 'of rock, paper, '
- 'or scissors to play:\n>> ')).lower()
- if player_choice == computer_choice:
- print ("\nIt is a tie!!")
- elif player_choice == "rock" and computer_choice == "paper":
- print ("\npaper beats rock -- You lost!!")
- elif player_choice == "paper" and computer_choice == "scissors":
- print ("\nscissors beats paper -- You lost!!")
- elif player_choice == "scissors" and computer_choice == "rock":
- print ("\nrock beats scissors -- You lost!!")
- elif player_choice == "rock" and computer_choice == "scissors":
- print ("\nrock beats scissors -- You win!!")
- elif player_choice == "paper" and computer_choice == "rock":
- print ("\npaper beats rock -- You win!!")
- elif player_choice == "scissors" and computer_choice == "paper":
- print ("\nscissors beats paper -- You win!!")
- else:
- print('\nThats not a valid option.')
- game()
- def again():
- choice = raw_input("\nWould you like another game?\n>> ").lower()
- if choice in ["yes", 'y']:
- game()
- elif choice in ["no", 'n']:
- sys.exit()
- else:
- again()
- again()
- game()
Advertisement
Add Comment
Please, Sign In to add comment