Syntax error on elif statement


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<In what way does your code behave incorrectly? Include ALL error messages.>
i have a syntax error on line 18


<What do you expect to happen instead?>

from random import randint

options = ['ROCK', 'PAPER', 'SCISSORS']
message = {
  'tie' : "Yawn it's a tie!",
  'won' : "Yay you won! ",
  'lost' : "Aww you lost!",
  
}

def decide_winner(user_choice,computer_choice) :
  print "You've chosen %s" %(user_choice)
  print "The computer chose %s" %(computer_choice)
  if user_choice == computer_choice :
    print message["tie"]
    
    elif user_choice == options[0] and computer_choice == options[2]:
      print message["won"]
    elif user_choice == options[1] and computer_choice == options[0] :
      print message["won"] 
    elif user_choice == options[2] and computer_choice == options[1] :
      print message["won"]
    else :
      print message["lost"]
      
      
 def play_RPS() :
  user_choice = raw_input("Enter Rock, Paper or Scissors").upper()
  computer_choice = option[randint(0,2)]
  decide_winner(user_choice,computer_choice)
  
 play_RPS()

#2

your indent is off. the elif and else statement should follow the if condition, which is currently not the case. They (elif and else) are nested in the if clause (which is wrong)


#3

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