My code implementing rock, paper and scissors in Python, using dicts to hold choices.import randomchoices = ['rock', 'paper', 'scissors']def choice():    player_choice = raw_input('Choose rock, paper or scissors: ')    if player_choice.lower() in choices:        computer_choice = random.choice(choices)        play(player_choice, computer_choice)    else:        choice()def play(p_choice, c_choice):    win_table = {'rock' : {'rock':'It was a Tie', 'paper':'You Lose', 'scissors':'You Win'},                 'paper' : {'rock':'You Win', 'paper':'It was a Tie', 'scissors':'You Lose'},                 'scissors' : {'rock':'You Lose', 'paper':'You Win', 'scissors':'It was a Tie'}}    print 'Computer chose', c_choice    print win_table[p_choice][c_choice]    new = raw_input('Play again ? (Y/N):  ')    if new.lower() == 'y':         choice()    else:        print 'Have a nice day !'choice()win_table dictionary names are player choices and dictionary keys are computer choices, seems more efficient to me. I haven't run any memory usage tests, though.
Python rock paper scissors
python;python 2.7;rock paper scissors
Single Responsibility Principlechoice() should do one thing: get the player's choice. It does three things: gets the player's choice, picks a choice for the computer, and then plays. If we just drop the other two, we'd get down to:def choice():    player_choice = raw_input('Choose rock, paper or scissors: ')    if player_choice.lower() in choices:        return player_choice    else:        return choice()However, making this recursive isn't great. We could just run out of stack space. There's no advantage here. Let's just loop until done:def choice():    while True:        player_choice = raw_input('Choose rock, paper or scissors: ')        if player_choice.lower() in choices:            return player_choiceIt would be better to flip the namings here too, and call the function player_choice and the variable choice. Similarly, play() does too many things. Ideally, you'd want to structure your main like:while True:    player = player_choice()    ## JUST grab the player's choice    cpu = computer_choice()     ## JUST grab the CPU's choice    show_results(player, cpu)   ## JUST print the outcome    new = raw_input('Play again? (Y/N): ')    if new.lower() != 'y':        print 'Have a nice day!'        breakDetermining SuccessRight now, your win_table is explicitly listing all 9 cases. That's super repetitive. First of all, the message is the same regardless of which win case we're in, so you could simplify the win_table to actually be a table of wins:win_table = {'rock': ['scissors'],             'scissors': ['paper'],             'paper': ['rock']}if cpu in win_table[player]:    # You win!Or we can do this programmaticly. Rock, Paper, Scissors is a wheel. Rock > Paper > Scissors > Rock. We win if the opponent's choice is the next one along in the wheel. That is:if player == cpu:    # Tieelse:    idx = choices.index(player)    if cpu == choices[(idx + 1) % len(choices)]:        # We win    else:        # We lose