Struggling...Pls Help


#1


Doesn't run and doesn't say any error, so i think its the end of the program maybe the way i called the function but im sure and need some help ....pls help me out


#Rock,Paper,Scissors game
from random import randint
from time import sleep
options =["R", "P", "S"]
you_lost =  "You lost!"
you_win =  "You Win"
def decide_winner(user_choice, computer_choice):
  print ("You selected: %s" % user_choice)
  print "Computer selecting"
  sleep(1)
  print ("You selected : %s" % computer_choice)
  user_choice_index =  option.index(user_choice)
  computer_choice_index = option.index(computer_choice)
  if user_choice == computer_choice:
    print "Its a Tie"
  elif user_choice_index == 0 and computer_choice_index == 2:
    print "WIN_MESSAGE"
  elif user_choice_index == 1 and computer_choice_index == 0:
    print "WIN_MESSAGE"
  elif user_choice_index == 2 and computer_choice_index == 1:
    print "WIN_MESSAGE"
  elif user_choice_index >2:
    print "Error, invalid option was selected"
    return exit
  else:
    print "you've lost"
    
def play_RPS(decide_winner,user_choice, computer_choice):
  
  
  
  
  
  
  play_RPS()


#2

your play_RPS function is empty, is this suppose to be?


#3

thanks was a bit tired after several hours coding and i just didn't see the other tasks...sorry for that but even though it doesn't work

#Rock,Paper,Scissors game
from random import randint
from time import sleep
options = ["R", "P", "S"]
you_lost =  "You lost!"
you_win =  "You Win"
def decide_winner(user_choice, computer_choice):
  print ("You selected: %s" % user_choice)
  print "Computer selecting"
  sleep(1)
  print ("You selected : %s" % computer_choice)
  user_choice_index =  option.index(user_choice)
  computer_choice_index = option.index(computer_choice)
  if user_choice == computer_choice:
    print "Its a Tie"
  elif user_choice_index == 0 and computer_choice_index == 2:
    print "WIN_MESSAGE"
  elif user_choice_index == 1 and computer_choice_index == 0:
    print "WIN_MESSAGE"
  elif user_choice_index == 2 and computer_choice_index == 1:
    print "WIN_MESSAGE"
  elif user_choice_index >2:
    print "Error, invalid option was selected"
    return exit
  else:
    print "you've lost"
def play_RPS():
  print "Rock, Paper, Scissors?"
  user_choice =  raw_input("Select R for Rock, P for Paper, or S for Scissors: ")
  sleep(1)
  user_choice =  user_choice.upper()
  computer_choice = option[randint(0,len(options)-1)]
  decide_winner(user_choice, computer_choice)
  
  
  
  
  
  
  
  
  play_RPS()

#4

lets start here:

def play_RPS():
  print "Rock, Paper, Scissors?"
  user_choice =  raw_input("Select R for Rock, P for Paper, or S for Scissors: ")
  sleep(1)
  user_choice =  user_choice.upper()
  computer_choice = option[randint(0,len(options)-1)]
  decide_winner(user_choice, computer_choice)
  
  play_RPS()

the function call is inside the function, place it outside the function by removing the indent.

then this four lines:

options = ["R", "P", "S"]
user_choice_index =  option.index(user_choice)
computer_choice_index = option.index(computer_choice)
computer_choice = option[randint(0,len(options)-1)]

you called the variable options, make sense. Yes then when you try to access this list, you use option

Decide if you want to use options or option


#5

Yeah hahaha its working thanks a lot, ill try to be more focused in next projects. Thanks


#6