Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

game #4350

Closed
shubhamthumar opened this issue Jan 17, 2025 · 0 comments
Closed

game #4350

shubhamthumar opened this issue Jan 17, 2025 · 0 comments

Comments

@shubhamthumar
Copy link

import getpass
moves = {"rock":1 ,"paper":2,"scissors":3}
def play(player):
move = getpass.getpass("{}'s move: ".format(player))
if move in moves:
return moves[move] #return numeric value of move
print("Invalid Move")
play(player) #Recursion

def compare(player1 ,player2):
diff = player1 - player2
if((diff%2==0 and diff<0) or (diff%2==1 and diff>0)):
return True # Player 1 won
else:
return False # Player 2 won

while input("Wanna Play ? ").lower() in ["y","yes"]:
player1 = play("player1")
player2 = play("player2")
if (player1==player2):
print("\nDraw \n")
else:
winner = "Player 1" if (compare(player1 ,player2)) else "Player 2"
print(" \n{} won the game \n".format(winner))
print("Thank you for playing")

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Jan 17, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Jan 19, 2025
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

No branches or pull requests

2 participants