write me a function that will allow users to play rock paper scissors
时间: 2023-02-18 13:43:34 浏览: 128
你可以使用以下函数来实现石头剪刀布游戏:
def rock_paper_scissors(user1, user2):
if user1 == user2:
print("Draw!")
elif user1 == "rock":
if user2 == "scissors":
print("User 1 wins!")
else:
print("User 2 wins!")
elif user1 == "scissors":
if user2 == "rock":
print("User 2 wins!")
else:
print("User 1 wins!")
elif user1 == "paper":
if user2 == "rock":
print("User 1 wins!")
else:
print("User 2 wins!")
else:
print("Invalid input! You have not entered rock, paper or scissors, try again.")
rock_paper_scissors(user1, user2)
阅读全文