>
Code Monsters Academy
Home › Blog › Python games

Python Games With Player Input: Rock Paper Scissors and a Text Adventure

Both games read what the player types. That makes them a good next step after print(): you practise comparisons, loops and simple state.

Rock, paper, scissors

import random

options = ["rock", "paper", "scissors"]
cpu = random.choice(options)
you = input("rock, paper or scissors? ").lower()
print("Computer chose", cpu)
if you == cpu:
    print("Draw")
elif (you, cpu) in [("rock","scissors"), ("paper","rock"), ("scissors","paper")]:
    print("You win")
else:
    print("Computer wins")

Sample output

(run it and you will see the prompt printed in the terminal)

A text adventure with three rooms

rooms = {
    "hall": {"north": "kitchen", "east": "garden"},
    "kitchen": {"south": "hall"},
    "garden": {"west": "hall"},
}
here = "hall"
while True:
    print("You are in the", here, "| exits:", ", ".join(rooms[here]))
    move = input("Go (or quit): ").lower()
    if move == "quit":
        print("Thanks for playing!")
        break
    if move in rooms[here]:
        here = rooms[here][move]
    else:
        print("No exit that way")

Sample output

(run it and you will see the prompt printed in the terminal)

Common mistakes

Variations to try

More Python games

Overview of the whole set: Python games code to copy and paste.

If you prefer learning by playing, Code Monsters Academy teaches the same ideas one level at a time.