I am stuck in Rock Paper Scissors Machine Learning Project:

I am using “win-stay,lose_shift” strategy to complete the project but the winning percentage is lower than it should be. Can someone tell me what I’m doing wrong or what should I change.

def player(prev_play,my_history = []):
    winning_set = { 
    if len(my_history)>1:
      if (winning_set[my_history[-1]]==prev_play):
        guess = winning_set[prev_play]
        guess = winning_set[my_history[-1]]
      guess = "P"
    return guess

Here is a link to challenge.

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

The 4 opponents employ different strategies. You can see how they act by looking at their functions.