Skip to content

Instantly share code, notes, and snippets.

@stevencombs
Last active December 20, 2015 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevencombs/6216244 to your computer and use it in GitHub Desktop.
Save stevencombs/6216244 to your computer and use it in GitHub Desktop.
# Computer the bill for a shopping list
# A Codecademy Python (Making a Purchase) assignment
# Dr. Steven B. Combs, coding novice
groceries = ["banana", "orange", "apple"]
stock = {
"banana": 6,
"apple": 0,
"orange": 32,
"pear": 15
}
prices = {
"banana": 4,
"apple": 2,
"orange": 1.5,
"pear": 3
}
# Code below is incorrect. Need to Redo!
def compute_bill(food):
total = 0
for cost in food:
total = total + prices[cost] * stock[total]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment