Basta Fazoolin'

You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!
https://www.codecademy.com/projects/practice/basta-fazoolin

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to [ask a good question]

I have had some difficulty in determining what solutions to use based off of the instructions given. When I see the project walkthrough they give the answers and I am like how did he come up with this solution? What is your process for determining what you need? I have a separate question as well how does the software know to add just the numbers up in the menu dictionary? I see a dictionary with a string such as pancakes and than a value for the price. How does it know to add up the values only?

 def calculate_bill(self, purchased_items):
    bill = 0
    for purchased_item in purchased_items:
      if purchased_item in self.items:
        bill += self.items[purchased_item]
    return bill

# if the iterization variable purchased item is in the the purchased_items arguement that was passed in line 39 than we add that items cost to the bill variable by the cost amount. my question is why does it not also add the string? I mean we cannot add strings so why is an error message not generated? 

When we poll a dictionary by key, the return is the value at that key. In Python terms, when we poll a dictionary by attribute, the return is its value.

It’s implied in the code because I named the key so therefore it knows the key and only returns the value! Of course!

1 Like