thecodezone.
The Code Zone
Short steps, at your pace · Free lessons and practice · Member video walkthroughs
Save your next small win.

Checking your account…

03.02 · Rock, Paper, Scissors / Learn · 18 min

Explain Rock, Paper, Scissors

The original solution prints an invalid-input warning but then continues to game_legend[user_input], which can raise KeyError. This browser adaptation puts the rest of the round inside else so invalid input stops safely. The recording remains an original reference, not a guarantee that every source line is correct.

Activity 2 of 2 in Rock, Paper, Scissors

All courses

Python Challenge Workbook / 03.02

Rock, Paper, Scissors review

Not started

Compare your approach with the original recording and an explained browser adaptation.

More options

Your lesson progress

Walkthrough: not startedPractice: not started

Empty: not started. Yellow: in progress. Green: complete. Marking the whole activity complete does not replace your test results. These circles save in this browser for this pilot.

Cartoon Rob reviews the game rules and valid or invalid outcomes for Rock, Paper, Scissors.
Rob’s comic strip · Rock, Paper, Scissors

ORIGINAL WALKTHROUGH · 17:36

Watch with Rob.

Pause whenever you want to try a change. You can return to the lesson at any time.

LEARN WITH THE CODE ZONE

Unlock this video walkthrough

Written lessons and coding practice are free. Video walkthroughs are included with a paid Code Zone membership or an active free trial.

Have a Code Zone website account? Use your learning account’s email to get a six-digit sign-in code, or use your existing website password.

Need a website account? Paid Skool members and active trial members can use the email from their membership questions to request a sign-in code. No invite link or Skool password needed.

Close this window to keep practicing. After signing in, you’ll return to this lesson.

Video walkthroughs are included with an active Code Zone membership. The written lesson and practice are free.

Open video & code editor (opens in a new tab)

Starter source code for VS Code

Copy the source below or download the file to follow along in VS Code.

The download includes a lesson link in each file and a README so you can find your way back.

main.py
main.pypython · example
# Code along: Rock, Paper, Scissors review
# Build your own version as you follow the video.
import random

Watch the original solution

Try the challenge before reading this review. Watch Rob’s original 17:36 solution recording above. Use theater mode to watch and code side by side, or pop out the editor into its own window. Keep your challenge editor open in another tab to compare your own approach.

Validate before dictionary lookup

The original solution prints an invalid-input warning but then continues to game_legend[user_input], which can raise KeyError. This browser adaptation puts the rest of the round inside else so invalid input stops safely. The recording remains an original reference, not a guarantee that every source line is correct.

A dictionary connects codes to labels

The supplied game_legend maps a short code such as R to Rock. Check membership in choices before looking up the full word. The tuple supplies the only three legal computer choices.

Cover all nine pairs

Handle matching moves first. Then list the three player-winning pairs. The remaining three valid unequal pairs are computer wins. Test each pair rather than assuming a single successful round proves the game is complete. Bonus: replay, reprompt on invalid moves or keep score.

One explained browser version

This is one valid approach. The challenge accepts other implementations that meet its observable game contract. Reading or copying this example does not award a pass or replace your saved work.

One possible game implementation
game.pypython · example
import random

game_legend = {"R": "Rock", "P": "Paper", "S": "Scissors"}
choices = ("R", "P", "S")
user_input = input("Choose Rock (R), Paper (P), or Scissors (S): ").strip().upper()
if user_input not in choices:
    print("Invalid choice. Please choose Rock (R), Paper (P), or Scissors (S).")
else:
    computer_choice = random.choice(choices)
    print(f"You chose: {game_legend[user_input]}")
    print(f"Computer chose: {game_legend[computer_choice]}")
    if user_input == computer_choice:
        print("It's a tie!")
    elif (user_input == "R" and computer_choice == "S") or (user_input == "P" and computer_choice == "R") or (user_input == "S" and computer_choice == "P"):
        print("You win!")
    else:
        print("Computer wins!")
Open workspace to paste this example (opens in a new tab)

Build it one step at a time

Prefer learning by typing? Work through short instructions, run the Python code and check each change before continuing. Your guided project saves separately from the challenge below.

The mini-lesson opens in a new tab. Your own code carries forward; each step has a focused check and an optional hint.

Start mini-lesson(opens in a new tab)

6 steps · Saved work · Instant feedback

Ready to try it?

Practice in your browser and see your results.

Progress details

Have a question?

Ask the Code Zone community.

Ask a question in The Code Zone (opens in a new tab)

Continue learning

ONE STEP FORWARD

Explain which branch runs for invalid input, a win, a loss and a normal next turn before moving on.