Python - 29

Python - 29: Building a Simple Inventory System

Inventory systems track items, quantities, and updates. This project combines loops, dictionaries, functions, and conditions.

✦ Python Editor
▶ Output

👀 Show Example Solution
items = []

def add_product(name, stock):

    product = {
        "name": name,
        "stock": stock
    }

    items.append(product)

add_product("Laptop", 3)

add_product("Keyboard", 10)

for product in items:

    print(product["name"])

    print(product["stock"])

    print("---")

for product in items:

    if product["stock"] < 5:

        print("Restock Needed:")
        print(product["name"])