Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion lab-python-error-handling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,36 @@
"metadata": {},
"outputs": [],
"source": [
"# your code goes here"
"# your code goes here\n",
"def initialize_inventory(products):\n",
" inventory = {}\n",
" for product in products:\n",
" quantity = int(input(f\"Enter the quantity for {product}: \"))\n",
" inventory[product] = quantity\n",
" return inventory\n",
"def get_costumers_orders():\n",
" costumers_order = set()\n",
" \n",
" add_product = \"yes\"\n",
" while add_product.lower() == \"yes\":\n",
" product = input(\"Enter the product name (t-shirt/pants/shoes/jacket): \").lower()\n",
" costumers_order.add(product)\n",
" add_product = input(\"Do you want to add another product? (yes/no): \").lower()\n",
" return costumers_order\n",
"def update_inventory(costumers_order, inventory):\n",
" for product in costumers_order:\n",
" if product in inventory:\n",
" inventory[product] -= 1\n",
" return inventory"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "21c5f2f2",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down