Lazo Lab Sign up

Python Projects & Skills / Games

Lesson 7 of 28

Rock, paper, scissors

Store what beats what in a dictionary, so the game logic is one line instead of nine ifs.

Key points

  • Dictionaries simplify rules
  • random.choice picks the computer's move
  • Track a best-of-five score
beats = {"rock": "scissors", "paper": "rock", "scissors": "paper"}
if beats[me] == cpu:
    print("You win")
Watch a video on thisOpens YouTube search results for “Rock, paper, scissors” in a new tab

Quiz · +10 XP

In the dictionary above, what does rock beat?

Log in to save progress and earn XP.