Skip to content
Open

final #596

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
31 changes: 29 additions & 2 deletions lab-python-flow-control.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,38 @@
"\n",
"3. Instead of updating the inventory by subtracting 1 from the quantity of each product, only do it for the products that were ordered (those in \"customer_orders\")."
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "c4f10172",
"metadata": {},
"outputs": [],
"source": [
"products =[\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n",
"\n",
"inventory = {}\n",
"for product in products:\n",
" inventory[product] = int(input(f\"Introduce la cantidad de {product}: \"))\n",
"\n",
"customer_orders =set()\n",
"\n",
"add_another = 'yes'\n",
"while add_another == 'yes' :\n",
" product = input(\"Qué producto quieres añadir?: \") \n",
" customer_orders.add(product)\n",
" add_another = input(\"Desea seguir añadiendo?\").lower()\n",
"\n",
"\n",
"for product in customer_orders:\n",
" if product in inventory:\n",
" inventory[product] -= 1"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "base",
"language": "python",
"name": "python3"
},
Expand All @@ -55,7 +82,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.13.9"
}
},
"nbformat": 4,
Expand Down