Getting invalid syntax on colon after my if statement



<In what way does your code behave incorrectly? Include ALL error messages.>
on line 14 my if user_choice == computer_choice: I get a invalid syntax and the colon highlighted in red in python 3.6.5

<What do you expect to happen instead?>
to ask user for inout and after input was put in run the program to end

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 selected: {}".format(user_choice))
  print("Computer seleceted: {}".format(computer_choice)
  if user_choice == computer_choice:
  elif user_choice == options[0] and computer_choice == options[2]:
  elif user_choice == options[1] and computer_choice == options[0]:
  elif user_choice == options[2] and computer_choice == options[1]:

def play_RPS():
  user_choice = input("Enter Rock, Paper, or Scissors: ")
  user_choice = user_choice.upper()
  computer_choice = options[randint(0, 2)]
  decide_winner(user_choice, computer_choice)


please look at the line of code above the error message:

print("Computer seleceted: {}".format(computer_choice)

notice anything odd?


thanks I guess I got sloppy and didn’t even notice that I had two different named var and thats why I got the error code


i was referring to the parentheses


okay sorry but I am a noob and only have some idea about converting python 2 to python 3 i.e. (using. format instead of % or {} instead of %s for user input and input instead of user_input just to name a few but to the point i wanted to declare a str with the randint function that the computer selected to the user i.e. I select paper “you selected paper” then after the randint function runs for the computer it should say " Computer selected: {what ever randint was selected}" so is it the fact I didn’t put a space between {} and " or what I do apologize I did wind up re doing the exercise and got it to run but I still want to know what I messed up on so I can learn and identify my weaknesses or what is a common factor that I over look

print("Computer seleceted: {}".format(computer_choice) // missing ) to close print

you just miss a ) which gives you the error.


okay I see that now that you pointed it out thanks honestly that thing had stumped for hours and its funny to find out it was all because I didn’t make sure I had two ) instead of one thank you a lot for taking time to reply and explain my error to me.


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