How do I print this?


#1

How do I print this? How do I call the function to print? I got a check mark but it shows an error and doesn’t print

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]
      stock[item] -= 1
  return total
print compute_bill()

https://www.codecademy.com/courses/learn-python/lessons/a-day-at-the-supermarket/exercises/lets-check-out?action=resume_content_item


#2

the error in console:

TypeError: compute_bill() takes exactly 1 argument (0 given)

is pretty helpful, you have a parameter (food) but then when you call the function, you don’t provide any argument, so python doesn’t know what value to give the parameter


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.