Skip to content

Instantly share code, notes, and snippets.

@jgarciabu
Last active August 21, 2017 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgarciabu/24a32e5f458a6707e2f9dc3f5749691a to your computer and use it in GitHub Desktop.
Save jgarciabu/24a32e5f458a6707e2f9dc3f5749691a to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 27 15:15:31 2017
@author: Jeff Garcia
Make a two-player Rock-Paper-Scissors game. (Hint: Ask for player plays
(using input), compare them, print out a message of congratulations to the
winner, and ask if the players want to start a new game)
"""
choices = ['Rock','Paper','Scissors', 'rock', 'paper', 'scissors']
restart = ['Yes', 'Y', 'yes', 'y', 'No', 'no', 'N', 'n']
again = 'Yes'
while again in ('Yes', 'Y', 'yes', 'y'):
player1 = input("Player 1, do you choose rock, paper or scissors:")
if player1 not in choices:
input("Your only choices are rock, paper, or scissors:")
player2 = input("Player 2, do you choose rock, paper or scissors:")
if player2 not in choices:
input("Your only choices are rock, paper, or scissors:")
if player1 in ('Rock', 'rock') and player2 in ('Paper', 'paper'):
print("Player 2 Wins!")
elif player1 in ('Rock', 'rock') and player2 in ('Scissors', 'scissors'):
print("Player 1 Wins!")
elif player1 in ('Rock', 'rock') and player2 in ('Rock', 'rock'):
print("It's a tie.")
elif player1 in ('Paper', 'paper') and player2 in ('Rock', 'rock'):
print("Player 1 Wins!")
elif player1 in ('Paper', 'paper') and player2 in ('Scissors', 'scissors'):
print("Player 2 wins!")
elif player1 in ('Paper', 'paper') and player2 in ('Paper', 'paper'):
print("It's a tie.")
elif player1 in ('Scissors', 'scissors') and player2 in ('Rock', 'rock'):
print("Player 2 wins!")
elif player1 in ('Scissors', 'scissors') and player2 in ('Paper', 'paper'):
print("Player 1 wins!")
elif player1 in ('Scissors', 'scissors') and player2 in ('Scissors', 'scissors'):
print("It's a tie.")
again = input("Would you like to play again?")
while again not in restart:
again = input("Would you like to play again?")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment