Rock, Paper, Scissors project. Unknown cause for error


I;m not sure what;s causing it. It tells me the traceback error line location but when looking over my code again i still can't fathom it. Any help would be great, thanks.

"""This program will simulate a game of rock paper scissors"""
from random import randint
from time import sleep

options = ["R", "P", "S"]
loss = "You lost!"
win = "Congratulations, you win!"

def decide_winner(user_choice, computer_choice):
  print "You selected %s" % user_choice
  print "Computer selecting..."
  print "The computer selected %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"It's a tie!"
  elif user_choice_index == 0 and computer_choice_index == 2:
    print win
  elif user_choice_index == 1 and computer_choice_index == 0:
    print win
  elif user_choice_index == 2 and computer_choice_index == 1:
    print win
  elif user_choice_index > 2:
    print"Invalid selection"
    print loss

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)]




user_choice = user_choice.upper

calling a method has the following syntax:


the parentheses are missing in your code, so you store the method in user_choice

then index() throws an error because the upper method is not in list


Thank you worked a treat :smile:


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