Hello! Hope everybody's fine.
Here I have written a RPS game:
1.How can I fix it?
2.Also any other suggestions for writing a simpler/shorter code for RPS game is much appreciated.
A huge thanks to everyone spending time answering the forums' questions.
Here I have written a RPS game:
player1 = input("Give player 1 a name:\n") player2 = input("Give player 2 a name:\n") while True: choice1 = input(f"{player1}, start the game:(rock/paper/scissors) ") choice2 = input(f"{player2}, it's your turn:(rock/paper/scissors) ") if choice1 == choice2: print("Same!") elif choice1 == 'rock': if choice2 == 'paper': print(f"{player2} wins!") else: print(f"{player1} wins!") elif choice1 == 'paper': if choice2 == 'scissors': print(f"{player2} wins!") else: print(f"{player1} wins!") elif choice1 == 'scissors': if choice2 == 'rock': print(f"{player2} wins!") else: print(f"{player1} wins!") else: print("Check the spelling.") if input("Continue?(y/n) ") == 'n': breakThe problem is that this line:
print("Check the spelling.")executes only when the 1st player misspells the input, and doesn't take the 2nd player's input into account.
1.How can I fix it?
2.Also any other suggestions for writing a simpler/shorter code for RPS game is much appreciated.
A huge thanks to everyone spending time answering the forums' questions.
