inventory = {'Dress': 200, 'Pants': 100, 'Shorts': 250, 'Tops': 250, 'Coats_and_Jacket': 150, 'Shoes': 250, 'Accessories': 150}
sales = {'Accessories': 25, 'Shorts': 100, 'Dress': 75, 'Pants': 50, 'Tops': 175, 'Coats_and_Jacket': 120 }
max_inventory = {}
max_sales = {}
result = {}
print("Items with maximum inventory are the following:")
for name,stock in inventory.items():
if stock == max(inventory.values()):
max_inventory[name] = stock
print(max_inventory)
print()
print("Items with maximum sale are the following:")
for name,sale in sales.items():
if sale == max(sales.values()):
max_sales[name] = sale
print(max_sales)
print("Current inventory is the following:")
for name,value in inventory.items():
if name in sales.keys():
result[name] = inventory.values() - sales.values()
result
I have searched about this and none of them is the one I have learn in class ( yet ) so Is there an easy way to subtract 2 values of list?
and also how do I do it in Pythonic way (using only list comprehension )?