Make a Tiny Game
beginner30 XP

Guess the Number Game

Build a guessing game about continents and planets.

Guess the Number Game 🎯

Time to put it all together: variables, loops and decisions. You're building a game!

Lists: many things in one box

A list holds several things in order, inside square brackets:

Python
guesses = [3, 9, 7]

for guess in guesses:
    print(guess)

The loop takes each item from the list, one at a time.

More choices with elif

elif means "else if": another check to try.

Python
secret = 7   # the number of continents on Earth 🌍
guesses = [3, 9, 7]

for guess in guesses:
    if guess < secret:
        print(guess, "is too low")
    elif guess > secret:
        print(guess, "is too high")
    else:
        print(guess, "is right! You win!")

Python checks if first, then elif, then else, and runs only the first one that's true.

💡

💡 On this website Python can't stop and wait for you to type, so we put the guesses in a list. On your own computer you could use input() to ask a friend to guess!

🎮 Make it yours

Change the secret to something you know:

  • 8 planets in our solar system 🪐
  • 5 oceans on Earth 🌊
  • 206 bones in an adult's body 🦴

🎉 You did it!

You can now make Python talk, remember, calculate, draw, repeat and decide. That's what real programmers use every day.

Want to keep going? In our live Python classes, kids build bigger games and projects with a real teacher, and unlock new Hat Quest levels to earn their White, Yellow and Green hats. 🎩 See how kids earn hats →

⌨️

Type it yourself

Don't just read it — type the example from above into the box, press Run ▶, and watch what happens. Typing it yourself is how it really sticks! Stuck? Tap Show example.

Python · Playground
Output
Press ▶ Run to see your code come to life…

Quick check

01/5
What does elif mean?