diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index f4c7391..f397f2c 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -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" }, @@ -55,7 +82,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.9" } }, "nbformat": 4,