Skip to content

Conversation

Peyman2012
Copy link

def get_winner(p1, p2):
if p1 == p2:
return "It's a tie!"

elif p1 == 'rock':
if p2 == 'scissors':
return "First player wins!"
else:
return "Second Player wins!"
elif p1 == 'scissors':
if p2 == 'paper':
return "First player win!"
else:
return"Second player wins!"
elif p1 == 'paper':
if p2 == 'rock':
return "First player wins!"
else:
return "Second player win!"
else:
return "Invalid input!"
loop=True
while loop:
player1 = input("First player: rock, paper or scissors: ")
player2 = input("Second Player: rock, paper or scissors: ")
if player1=='E' or player2=='e':
loop= False
print(get_winner(player1, player2))

def get_winner(p1, p2):
   if p1 == p2:
       return "It's a tie!"

   elif p1 == 'rock':
       if p2 == 'scissors':
           return "First player wins!"
       else:
           return "Second Player wins!"
   elif p1 == 'scissors':
       if p2 == 'paper':
           return "First player win!"
       else:
           return"Second player wins!"
   elif p1 == 'paper':
       if p2 == 'rock':
           return "First player wins!"
       else:
           return "Second player win!"
   else:
       return "Invalid input!"
loop=True      
while loop:
    player1 = input("First player: rock, paper or scissors: ")
    player2 = input("Second Player: rock, paper or scissors: ")
    if player1=='E' or player2=='e':
        loop= False
    print(get_winner(player1, player2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant