Getting Syntax Error. Struggling with why


#1



I keep getting a syntax error on line 32, which is the decide_winner(user_choice, computer_choice) with the arrow pointing between r(

I can't figure out why. I have tried deleted and retyping the line. The indentation is in line with the rest. Any ideas? Further is there any bad habits I am developing even if my code is correct? Don't want to do that for obvious reasons. Thank you.


# Rock, paper, scissors game
from random import randint
from time import sleep
options = ["R", "P", "S"]
YOU_LOST = "You lost the game!"
YOU_WIN = "You won the game!"
def decide_winner(user_choice, computer_choice):
  print "You selected %s" % user_choice
  print "Computer selecting..."
  sleep(1)
  print "Computer seclected %s" % compute_choice
  user_choice_index = options.index(user_choice)
  computer_choice_index = options.index(computer_choice)
  if user_choice_index == computer_choice_index:
    print "The game is a tie!"
  elif user_choice_index == "R" and computer_choice_index == "S":
		print YOU_WIN
  elif user_choice_index == "P" and computer_choice_index == "R":
  	print YOU_WIN
  elif user_choice_index == "S" and computer_choice_index == "P":
    print YOU_WIN
  elif user_choice_index > 2:
    print "Invalid Pick"
  else:
    print YOU_LOST
def play_RPS():
  print "Rock, Paper, Scissors game!"
  user_choice = raw_input("Select R for Rock, P for Paper, or S for Scissors:")
  sleep(1)
  user_choice = user_choice.upper()
  computer_choice = options[randint(0,len(options)-1)
  decide_winner(user_choice, computer_choice)
play_RPS()


#2

I'm still sifting through to find the cause, but here you have an error:

print "Computer seclected %s" % compute_choice

It should be computer_choice


#3

Whew, found it. Within your play_RPS method, make sure you close out the computer_choice line.


#4

Dang! Amazing how simple things are missed. Thanks for your help!


#5

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