Add a Simple Inventory
STEP 3 β Add a Simple Inventory
Because every hero needs a potion for βoopsβ moments.
We give the player potion.
inventory = [{"name": "Potion", "heal": 30}]
def use_item(player, inventory):
if inventory:
item = inventory.pop(0)
player["health"] += item["heal"]
print(player["name"], "uses", item["name"], "+", item["heal"])
else:
print("No items left!")
Explanation:
- The inventory is a list
- Each Item is a dictionary
- pop(0) removes the first item
- The player heals based on the itemβs value This is your first real item system β simple, clean, and powerful


