Basta Fazoolin? calculate_bill method

In step 10 of the Basta Fazoolin project you are asked to create a calculate_bill method. The following code works but I would like to know why self.items has purchased_item in square brackets?

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

I can’t find reference to it in past lessons. If anyone has the answer and possibly a link to a reference so I can read a bit about it it would be appreciated.
Thanks.

square brackets? maybe you’re paying too much attention to text and not enough to actions.

what actions should your functions carry out?
pair them up to your code, and then, what got paired with these square brackets?

you’re making some function.
it accepts input, some initial state. what things are available?
what operations do those things support?
what is the purpose of your function, should it DO something, or create some value?
how does that purpose relate to the things you initially have access to?

maybe some of that has to do with list or dict
what do those do? what operations do those support, what do those operations look like?
after learning basic operations for the types involved, you could compare those operations with the things you need to do, and leverage those basic operations to carry out the steps you had planned out

Try printing out self.items and seeing how it is stored. That should answer your question, assuming you understand how to interact with Python data structures.

I’ve solved it. It’s basically accessing the value for the keys in a dictionary.
Seems I’d gotten confused with the syntax for accessing values in dictionaries.