My code passes me along. I get the green button and the game plays well until....
I enter an "invalid choice". We write an interesting line or two to deal with it and low and behold it throws exceptions. Advisors couldn't make it work either. I have the code I wrote here, and a solution a friend helped me come up with (all his work, above my current knowledge level).
"""This is a rock paper scissors game. I am writing now to justify the term mulitline comment and make all of those quotation marks work for a living!""" from random import randint from time import sleep options = ["R", "P", "S"] lose_msg = "You lost!" win_msg = "You win!" def decide_winner(user_choice, computer_choice): print "Your selection: %s" % user_choice print "Computer selecting..." sleep(1) print "The computer's choice: %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_msg elif user_choice_index == 1 and computer_choice_index == 0: print win_msg elif user_choice_index == 2 and computer_choice_index == 1: print win_msg elif user_choice_index > 2: print "Invalid Choice!" return else: print lose_msg def play_RPS(): print "Rock, Paper, Scissors" user_choice = raw_input("Select R for rock, P for Paper, or S for scissors\n") sleep(1) user_choice = user_choice.upper() #computer_choice = options [randint(0,2)] computer_choice = options [randint(0, len(options)-1)] decide_winner(user_choice, computer_choice) play_RPS()
So, that's how I did it, and it passed me. But as stated won't deal with garbage input from the user. Chime in when you see my error, or if you have noticed the same thing yourself. I have an experienced friend help me from time to time, he was as puzzled as the Advisors I've chatted with.
Thanks again, have an interesting day!
PS, if you're interested in the optional solution I'll post in a later reply to avoid confusion.