Python Forum
Rock, Paper, Scissors Game
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rock, Paper, Scissors Game
#1
Hi everyone,
I am new to python and I am creating a rock, paper, scissors game. I do not get an error in my code, however, when I run it and input rock, paper or scissors as my option, it returns "none". I've research everywhere and I am completely stuck and I really want to understand what I am doing wrong.

Below is my python code:

# Make a two-player Rock-Paper-Scissors game. (Hint: Ask for player plays (using input),
# compare them, print out a message of congratulations to the winner, and ask if the
# players want to start a new game)
# Rock beats scissors
# Scissors beats paper
# Paper beats rock

print("Welcome to Rock, Paper, Scissors game: This is a two-player game. Player 1 and Player 2 will choose rock, "
      "paper, or scissors respectively\n")

p_1 = input("Player 1, choose rock, paper, or scissors: ")
p_2 = input("Player 2, choose rock, paper, or scissors: ")

def play (player_1, player_2):
    if player_1 == player_2:
        return play_again()

    elif player_1 == 'rock'.lower():
        if player_2 == 'scissors'.lower():
            return "Rock hits scissors. Player 1 win!"

    elif player_1 == 'paper'.lower():
        if player_2 == 'scissors'.lower():
            return "Scissors cut paper. Player 2 wins"

    elif player_1 == 'scissors'.lower():
        if player_2 == 'rock'.lower():
            return "Rock hits scissors. Player 2 wins!"

    elif player_1 == 'rock'.lower():
        if player_2 == 'paper'.lower():
            return "Paper covers rock. Player 2 wins!"

    elif player_1 == 'scissors'.lower():
        if player_2 == 'paper'.lower():
            return "Scissors cut paper. Player 1 wins!"

    elif player_1 == 'paper'.lower():
        if player_2 == 'rock'.lower():
            return "Paper covers rock. Player 1 wins!"
        else:
            return "Paper wins"
    else:
        print("Invalid choice. Type either, type rock, paper, or scissors.")
        return play(p_1, p_2)

print(play(p_1, p_2))

def play_again ():
    if input("Try again?") == "yes".lower():
        return play(p_1, p_2)
Reply


Messages In This Thread
Rock, Paper, Scissors Game - by kramon19 - Jan-10-2020, 03:10 AM
RE: Rock, Paper, Scissors Game - by sandeep_ganga - Jan-10-2020, 07:14 AM
RE: Rock, Paper, Scissors Game - by perfringo - Jan-10-2020, 08:18 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I attempted to make a rock paper scissors bot for homework Intellectual11 3 2,978 Jun-24-2021, 08:00 PM
Last Post: deanhystad
Question Rock, paper, scissors spelling error banidjamali 6 3,313 Jan-19-2021, 02:51 PM
Last Post: banidjamali
  I need help with a python Rock Paper Scissors game urgently. Riff_Raff 3 5,939 Dec-05-2018, 09:13 PM
Last Post: nilamo
  Rock, Paper, Scissors Advanced that saves, loads, and keeps statistics EvanCahill 0 5,249 Jul-21-2018, 07:32 PM
Last Post: EvanCahill
  Rock Paper Scissors Warmlawpk441 4 5,120 Oct-11-2017, 10:55 AM
Last Post: gruntfutuk
  Rock paper scissors game samiraheen 3 6,461 Oct-03-2017, 07:07 PM
Last Post: buran
  The Python Book altered rock paper scissors Python_Noob 0 2,957 Sep-18-2017, 06:13 AM
Last Post: Python_Noob
  HELP---problems with rock paper scissors games kalt91 2 4,191 Sep-15-2017, 04:51 PM
Last Post: micseydel
  Rock, Paper, Scissors game help.. hentera 3 5,143 May-19-2017, 10:56 PM
Last Post: ichabod801
  Rock Paper Scissors game codeobri 3 13,502 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