Skip to content

Update Rock-paper-scissor.md #15

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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))
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant