【发布时间】:2023-01-13 15:45:36
【问题描述】:
字符串可以有任何外壳。 Rock, ROCK, rock 都是可能和有效的。 任何人都可以帮助我的代码接受任何情况,如 rOcK 和所有...?
player1 = input('Enter rock/paper/scissors: ')
player2 = input('Enter rock/paper/scissors: ')
if (player1 == player2): print("The game is a Tie")
elif (player1 == 'rock' and player2 == 'scissors'): print("player 1 wins")
elif (player1 == 'rock' and player2 == 'paper'): print("player 2 wins")
elif (player1 == 'paper' and player2 == 'rock'): print("player 1 wins")
elif (player1 == 'paper' and player2 == 'scissors'): print("player 2 wins")
elif (player1 == 'scissors' and player2 == 'paper'): print("player 1 wins")
elif (player1 == 'scissors' and player2 == 'rock'): print("player 2 wins")
else: print("Invalid input")
我的代码运行完美,只是不知道如何编码以允许它接受任何情况。
【问题讨论】:
标签: python