Why did nothing print to the screen when I pressed Run?


#1

Question

Why did nothing print to the screen when I pressed Run?

Answer

To see your results be sure to call your compute_bill() function in a print statement and pass it the shopping_list list variable as an argument. Like this: print compute_bill(shopping_list).


FAQ: Learn Python: A Day at the Supermarket - Let's Check Out!
#3

How do we compute for the different number of fruits that we want the compute_ bill function to perform. Currently it is returning the answer 5.5 for the parameter (shopping _list) as it is considering only a single amount for each fruit. When I try to convert (shopping_list) to a dictionary and add different values for the keys(fruits), it returns the same value 5.5 ?


#4

shopping_list represents a list of products the customer wants to buy. The customer can’t determine the price, the prices are fetched from prices dictionary. So if prices of products need to change, prices needs to be changed

we can pass different lists to compute_bill, which represents customers. for example:

print compute_bill(["banana", "orange", "apple", "banana", "orange", "apple"])

#5

Thank you for the reply. Besides the method that you have given above, what would be the other methods, if we were to calculate the total bill for the various quantities of each fruit that the customer would buy ?


#6

at the moment, nothing. We need to provide the fruit multiple times as string, or modify the code.