从用户1获取输入
player_1 = input("Enter your choice player_1 from rock,paper or scissor: ")
从玩家2获取输入
player_2 = input("Enter your choice player_2 from rock,paper or scissor: ")
岩石剪刀规则1-纸张覆盖岩石2摇滚节拍剪刀3-剪刀剪纸
answer = []
while True:
if player_1 == player_2:
print("The game is tied sorry!!")
elif player_1 == "paper" and player_2 == "scissor":
print("scissor beats paper player_2 won")
elif player_1 == "scissor" and player_2 == "paper":
print("scissor beats paper player_1 won")
elif player_1 == "rock" and player_2 == "paper":
print("paper covers rock player_2 won")
elif player_1 == "paper" and player_2 == "rock":
print("paper covers rock player_1 won")
elif player_1 == "scissor" and player_2 == "rock":
print("rock breaks scissor player_2 won")
elif player_1 == "rock" and player_2 == "scissor":
print("rock breaks scissor player_1 won")
answer = input("Do you want to play the game again? y or n : ")
if answer == "y":
continue
else:
break
1 回答
如果选择n,则在选择y时退出将继续 .