Rock,Paper, Scissors, Help me look over my code. i don't know what I did wrong


#1

it said my line 16 problem, but I have no idea what is going on.
please help me look over my cod. thax

`


#2

Here is the problem:

def decide_winner(user_choice, computer_choice):
  print "You selected: %s" % (user_choice)
  # print computer selecting...
  # sleep for 1 second
  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 "It's 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 "Invalid selection!"
    return
        else:
    print LOSS_MESSAGE

Your indentation is all messed up
This should fix it:

def decide_winner(user_choice, computer_choice):
    print "You selected: %s" % (user_choice)
    # print computer selecting...
    # sleep for 1 second
    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 "It's 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 "Invalid selection!"
        return
    else:
        print LOSS_MESSAGE

#3

i modified it. follow ur code to fix it. and it showed the message
"on line 14, if user_choice_index == computer_choice_index:
indentation error: unexpected indent "


#4

Found the error, you used a 2-space indent, whereas I used a 4-space indent.
Change all indents to use 2 spaces or 4-spaces
This the code for the 4-space indent: https://gist.github.com/blackk100/c3c11a5314fde679b920ac4e63c3a1d5.js


#5

got it !!! fix it !!! thank you so much


#6

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