Skip to content

Instantly share code, notes, and snippets.

Created July 22, 2015 08:41
Show Gist options
  • Select an option

  • Save anonymous/fd33703e758be9f4f03e to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/fd33703e758be9f4f03e to your computer and use it in GitHub Desktop.
shopping_list = ["banana", "orange", "apple"]
stock = {
"banana": 6,
"apple": 0,
"orange": 32,
"pear": 15
}
prices = {
"banana": 4,
"apple": 2,
"orange": 1.5,
"pear": 3
}
def compute_bill(food):
total = 0
for item in food:
if stock[item] > 0:
total = prices[item] + total
stock[item] = stock[item] - 1
return total
print compute_bill(shopping_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment