Created
October 14, 2017 15:53
-
-
Save xsaamiir/8c577ec2a1c935e8e55d265ed34c6c04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def check_input(user_input): | |
allowed = ["rock", "paper", "scissors"] | |
if user_input in allowed: | |
return user_input | |
return check_input(input("Please enter a valid input: ")) | |
print(""" | |
Welcome to rock, paper, scissors. | |
This is a two players game, please type rock, paper, or scissors when asked for input | |
""") | |
again = "y" | |
while(again == "y"): | |
player1 = check_input(input("Player 1 : ")) | |
player2 = check_input(input("Player 2 : ")) | |
if player1 == player2: | |
print("\nIt's a tie, please try again :)\n") | |
if player1=="rock" and player2=="paper": | |
print("\nPlayer 2 won\n") | |
if player1=="rock" and player2=="scissors": | |
print("\nplayer 1 won\n") | |
if player1=='paper' and player2=='scissors': | |
print("\nPlayer 1 won\n") | |
if player1=='paper' and player2=='rock': | |
print('\nPlayer 2 won\n') | |
if player1=='scissors' and player2=='rock': | |
print('\nPlayer 2 won\n') | |
if player1=='scissors' and player2=='paper': | |
print('\nPlayer 1 won\n') | |
again = input("\nDo you want to play again ? (y/n)\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment