Inventory manager
Orla Hi. The cargo hold is a mess. We're running out of things we don't know we're running out of and ordering duplicates of things we have plenty of. I need a proper inventory tool. Add items, update quantities, save everything to a file between sessions. Something the whole crew can actually use 📦
What you're building
Commands: add / update / list / remove / quit
> add
Item name: Widget A
Quantity: 100
Price: 2.49
Added.
> list
Widget A qty: 100 £2.49 each total value: £249.00
> update
Item: Widget A
New quantity: 85
Updated.
> quit
Inventory saved to inventory.json.What you'll need
- Classes and objects — an
Itemclass for individual products, anInventoryclass to manage the collection - Files and exceptions — saving to and loading from JSON, catching a missing file on first run
- Dictionaries and lists — the underlying data before and after class wrapping
- Numbers and arithmetic — calculating total value per item
- Control flow and functions — the command loop, one function per command
Hints
An Item is a class with three attributes. Name, quantity, price. The Inventory manages a list of Items and exposes methods: add, update, remove, list.
Save on quit, load on start. Wrap the file load in a try/except so a missing file on the first run doesn't crash the script — just start with an empty inventory instead.
Total value is a display concern. Calculate quantity × price at print time. No need to store it as an attribute, it'll always be derivable.
Going further
Once the core tool works:
- Low stock alerts. When displaying the list, flag any item whose quantity drops below a threshold you define.
- Search. Add a
searchcommand that finds items by name, with partial matching. - Export report. Add an
exportcommand that writes a plain-text summary of current stock to a.txtfile.

