๐Ÿ PyQuest๐Ÿฐ Game: Haunted Mansion ยท ๐ŸŽ’ Step 3: Pack Your Backpack
โญ 0 XP๐Ÿ Python is waking upโ€ฆ

Step 3: Pack Your Backpack ๐ŸŽ’

Real adventure games let you pick things up and use them later. Time for an inventory! ๐Ÿ”‘

An inventory is just an empty list that grows:

inventory = []                 # empty backpack

inventory.append("key")        # found a key!
inventory.append("candle")     # ooh, a candle

print(inventory)               # โžœ ['key', 'candle']

.append() adds one thing onto the end of a list.

Later you check what you're carrying with the word in:

if "key" in inventory:
    print("๐Ÿ”“ The rusty key fits! The door swings open.")
else:
    print("๐Ÿ”’ Locked tight. If only you had a key...")

That's the magic move: something the player did way earlier changes what happens now. Suddenly your story has a memory. ๐Ÿง 

Your mission

Keep your story and add:

  1. inventory = [] at the very top
  2. At least one item to find โ€” inventory.append("key") on one of the paths
  3. A locked door at the end that only opens if "key" in inventory
  4. Print the backpack somewhere so the player can see what they have

Now the left door actually matters. ๐Ÿ˜ˆ

Your code

Press โ–ถ Run to see what your code does!