Python Forum
Rock, paper, scissors spelling error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rock, paper, scissors spelling error
#1
Question 
Hello! Hope everybody's fine.

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': break
The 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. Heart
Reply


Messages In This Thread
Rock, paper, scissors spelling error - by banidjamali - Jan-19-2021, 08:42 AM
RE: Rock, paper, scissors spelling error - by buran - Jan-19-2021, 08:52 AM
RE: Rock, paper, scissors spelling error - by buran - Jan-19-2021, 01:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I attempted to make a rock paper scissors bot for homework Intellectual11 3 2,981 Jun-24-2021, 08:00 PM
Last Post: deanhystad
  Rock, Paper, Scissors Game kramon19 2 5,429 Jan-10-2020, 08:18 AM
Last Post: perfringo
  I need help with a python Rock Paper Scissors game urgently. Riff_Raff 3 5,952 Dec-05-2018, 09:13 PM
Last Post: nilamo
  Rock, Paper, Scissors Advanced that saves, loads, and keeps statistics EvanCahill 0 5,259 Jul-21-2018, 07:32 PM
Last Post: EvanCahill
  Rock Paper Scissors Warmlawpk441 4 5,132 Oct-11-2017, 10:55 AM
Last Post: gruntfutuk
  Rock paper scissors game samiraheen 3 6,468 Oct-03-2017, 07:07 PM
Last Post: buran
  The Python Book altered rock paper scissors Python_Noob 0 2,959 Sep-18-2017, 06:13 AM
Last Post: Python_Noob
  HELP---problems with rock paper scissors games kalt91 2 4,196 Sep-15-2017, 04:51 PM
Last Post: micseydel
  Rock, Paper, Scissors game help.. hentera 3 5,146 May-19-2017, 10:56 PM
Last Post: ichabod801
  Rock Paper Scissors game codeobri 3 13,505 Apr-28-2017, 01:02 AM
Last Post: codeobri

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020