Combining Lists + Dictionaries

STEP 4 — Combining Lists + Dictionaries

(a.k.a. Building Real Game Data Systems Like a Future Dev Rockstar)

Up until now, you’ve been learning lists and dictionaries separately.

Cute.
Wholesome.
Educational.

But real games?

They don’t use them one at a time.

They mix them together like the ultimate coding smoothie.

This step is where your game suddenly becomes:

  • organized
  • scalable
  • professional
  • and honestly… kinda impressive

Let’s build some REAL game data.


1. A List of Enemies (Each Enemy Is a Dictionary)

This is how actual games store enemy data.


enemies = [
    {"name": "Goblin", "health": 30, "attack": 5},
    {"name": "Orc", "health": 50, "attack": 10},
    {"name": "Slime", "health": 20, "attack": 3}
]

for enemy in enemies:
    print(enemy["name"], enemy["health"], enemy["attack"])

Now you’re looping through multiple enemies, each with multiple stats.

This is how RPGs, battle systems, and enemy waves are built.

Click Run

2. An Inventory With Item Stats

Not just names — actual item attributes.


inventory = [
    {"name": "Sword", "damage": 10, "rarity": "Common"},
    {"name": "Bow", "damage": 8, "rarity": "Uncommon"},
    {"name": "Potion", "heal": 25, "rarity": "Common"}
]

for item in inventory:
    print(item["name"])

Your inventory now has depth.

It’s no longer a list of random objects — it’s a real system.

Click Run

3. A Shop System (List of Dictionaries)

This is how games store shop items.


shop = [
    {"name": "Iron Sword", "price": 20},
    {"name": "Health Potion", "price": 10},
    {"name": "Magic Scroll", "price": 50}
]

for product in shop:
    print(product["name"], "-", product["price"], "gold")

Congratulations — you just built a shop menu.

Click Run

4. Why This Combo Is So Powerful

Lists + dictionaries let you build:

  • enemy waves
  • inventory systems
  • shop menus
  • crafting recipes
  • quest logs
  • dialogue trees
  • level data
  • NPC profiles

This is the moment teens realize:

“Oh wow… I’m actually making a game.”


Practice (Your Turn!)

Mini-Challenge #1

Create a list called party with two characters, each a dictionary with:

  • name
  • health
  • level

Then loop through and print each character’s name.

Modify and Run

Mini-Challenge #2

Create a list called loot with three items, each a dictionary with:

  • name
  • value

Then print each item’s name and value.

Modify and Run

Why do lists and dictionaries make such a good couple?

Because one remembers the order, and the other remembers the details.