0

I am currently in the process of coding a simple rock, paper, scissors game in python. I am pretty confident all the functions work but I'm not sure if I'm doing the right thing when wrapping them in another function to play the game. I'm sure it's something really easy, but I can't seem to see what the issue is right now.

Here's the code:

import random

def get_computer_choice():
    rps = ["Rock", "Paper", "Scissors"]
    computer_choice = random.choice(rps)
    return computer_choice

def get_user_choice():
    user_choice = input("Choose Rock, Paper, or Scissors: ")
    return user_choice

def get_winner(computer_choice, user_choice):
    if computer_choice == user_choice:
        print("It is a tie!")

    elif computer_choice == 'Rock':
        if user_choice == 'Scissors':
            print("You lost")
        elif user_choice == 'Paper':
            print("You won!")

    elif computer_choice == 'Paper':
        if user_choice == 'Scissors':
            print("You won!")
        elif user_choice == 'Rock':
            print("You lost")

    elif computer_choice == 'Scissors':
        if user_choice == 'Rock':
            print("You won!")
        elif user_choice == 'Paper':
            print("You lost")

def play():
    get_computer_choice()
    get_user_choice()
    get_winner(get_computer_choice, get_user_choice)

play()
Adam Idris
  • 75
  • 1
  • 6
  • 1
    You have two basic choices here: store the results of the two choice functions in variables, then pass those variables to `get_winner()`, or simply write `get_winner(get_computer_choice(), get_user_choice())`. The way you have it, you're passing *the functions themselves* to `get_winner()`, which has no idea how to make use of functions; it wants strings. – jasonharper Nov 24 '22 at 16:40
  • 1
    `get_winner(get_computer_choice, get_user_choice)` will pass **the functions themselves** (`get_computer_choice` and `get_user_choice`) to `get_winner`, not what they returned. Please see the linked duplicate to understand how to do it properly. – Karl Knechtel Nov 24 '22 at 16:40

0 Answers0