Variables, ifs, loops, dicts and functions, learned by making a tiny dungeon you can actually beat.
Most Python courses make you add up shopping lists. We make a dungeon crawler instead. Every level adds one idea to the same game, and by the last one you have rooms, items, a locked door and a goblin fight. Install Python 3 from python.org (tick "Add to PATH" on Windows) and grab any text editor.
By Dispresso
Playing as a guest. Level 1 is yours to try. Sign in to save XP, keep a streak and earn the badge.
Sign in to saveLevel 1 of 6
About 6 minutes
Make a file called game.py and put this in it:
name = input("What's your name, adventurer? ")
print(f"Welcome, {name}. Find the way out.")
python game.pyinput(...) shows the text, waits for you to type, and gives back what you typed.name = ... stores it in a variable called name. Variables are labeled boxes.f"...{name}..." is an f-string. Anything in curly braces gets swapped for its value.On Mac and Linux the command might be python3. If python says it's not found, try that.
Fill the gap
Which function asks the player to type something?
name = ("What's your name? ")