Rock-Paper-Scissor Project


When calling the fuction in the end it says one of the parameters is not defined. decide_winner(user_choice, computer_choice)
user_choice is not defined.

i am pretty sure it is defined

from random import randint
from time import sleep
options = ["R", "P", "S"]
when_lost = "You Lose!"
when_win = "You Win!"
def decide_winner(user_choice, computer_choice):
  print "Your Choice is: %s" % user_choice
  print "The Computers choice is: %s" % computer_choice
  user_choice_index = options.index(user_choice)
  computer_choice_index = options.index(computer_choice)
  if user_choice_index == computer_choice_index:
    print "Its A Draw!"
  elif user_choice_index == 0 and comuter_choice_index == 2:
  elif user_choice_index == 1 and computer_choice_index == 0:
  elif user_choice_index == 2 and computer_choice_index == 1:
  elif user_choice_index > 2:
    print "Invalid Option! Try Again!"
def play_RPS():
  print "Rock, Paper or Scissors?"
  user_choice = raw_input("Select R for Rock, P for Paper, or S for Scissors: ")
  user_choice = user_choice.upper()
  computer_choice = options[randint(0,len(options)-1)]
decide_winner(user_choice, computer_choice)


the indention of this line:

decide_winner(user_choice, computer_choice)

is off. play_RPS() should call decide_winner.

because the indention is off, decide_winner is called before user_choice and computer_choice are defined


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.