Def play_RPS: ^ SyntaxError: invalid syntax


#1



hey, I tried to find a solution but I couldn't find any.
every time I try to run the project this error comes.

File "RPS.py", line 38
def play_RPS:
^
SyntaxError: invalid syntax


from random import randint
from time import sleep
options = ["R", "p", "S"]
LOSS_MESSAGE = "You lost!"
WIN_MESSAGE = "You win!"

def decide_winner(user_choice, computer_choice):
  print "You selected: %s" % user_choice
  print "Computer selecting..."
  sleep(1)
  print "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 "Its a tie!"
  elif user_choice_index == 0 and computer_choice_index == 2:
    print WIN_MESSAGE
  elif user_choice_index == 1 and computer_cohice_index == 0:
    print WIN_MESSAGE
  elif user_choice_index == 2 and computer_choice_index == 1:
    print WIN_MESSAGE
  elif user_choice_index > 2:
    print "You can't do that !"
  else:
    print LOSS_MESSAGE

def play_RPS:
  print "Rock, Paper, 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)
play_RPS()


#2

part of function declaration are parentheses:

 def example():

the parentheses, which may or may not contain parameters, are missing in your case


#3

ah right ! thank you very much it worked !
in the hint they didn't put any parentheses.


#4

The lesson tells you what you have to do, you have to create it

If you are unsure of syntax, you can always check documentation (i coded a few projects myself by now, it is far more important to be able to program, you can find the syntax in the documentation)

so it is a good thing, to be given some freedom, this will greatly improve your programming skills. I don't think the exercise should give you the syntax


#5

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