Skip to content

Instantly share code, notes, and snippets.

@julia-git
Created August 15, 2021 04:28
Show Gist options
  • Save julia-git/6ff9fa541334c6be4897d7a12bcb1e4f to your computer and use it in GitHub Desktop.
Save julia-git/6ff9fa541334c6be4897d7a12bcb1e4f to your computer and use it in GitHub Desktop.
veg_dict = {'cabbage': 3.57, 'carrot': 2.99, 'spinach': 4.13, 'asparagus': 3.56, 'artichoke': 4.00, 'lettuce': 3.83}
fruit_dict = {'peach': 0.65, 'banana': 0.23, 'watermelon': 2.45, 'apple': 0.99, 'dragonfruit': 1.23}
store_dict = {**veg_dict, **fruit_dict}
order1 = {'cabbage': 3, 'spinach' : 3, 'artichoke': 5, 'apple': 10, 'banana': 7}
order2 = {'dragonfruit': 10, 'apple': 4, 'lettuce': 2}
order1_total = 0
order2_total = 0
for item, quantity in order1.items():
order1_total += store_dict[item] * quantity
print(order1_total)
for item, quantity in order2.items():
order2_total += store_dict[item] * quantity
print(order2_total)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment