25 lines
641 B
Python
25 lines
641 B
Python
# Define the function that adjusts inventory levels
|
|
def update_inventory(inventory, items_sold):
|
|
# Iterate over each item in the dictionary
|
|
for product, quantity_sold in items_sold.items():
|
|
# Decrease the inventory by the quantity sold for each product
|
|
inventory[product] -= quantity_sold
|
|
|
|
# Inventory dictionary
|
|
inventory = {
|
|
"apples": 50,
|
|
"bananas": 75,
|
|
"oranges": 100
|
|
}
|
|
|
|
# Items sold dictionary
|
|
items_sold = {
|
|
"apples": 5,
|
|
"oranges": 15
|
|
}
|
|
|
|
# Update the inventory based on items sold
|
|
update_inventory(inventory, items_sold)
|
|
|
|
# Display the updated inventory
|
|
print("Updated inventory:", inventory) |