I am trying to understand Making Custom Containers

I took Mosh’s course on Python a week ago. I came across a statement that I found not easy to understand and I need some help to understand it. Take the following code which involves the get method which is used to extract a value from a dictionary: Below is the code of which there is one statement I could not understand.

the result is
tags = {“python”: 3}

What I could not understand is the statement that I indicated with the orange arrows. I am exttremely grateful if yo can extend me some help.


self.tags takes a list of tag
and sets it get method that takes in the same list, so as the get methods recieves the tag list, we add 1 to our varaiable self.tags[tag] and now uses the tag paramenter as our key in our dictionairy

1 Like

Thanks Jarvis. OK what happens when we bcall the add function

add(self, tag)

in terms of the class function which declares the tags as {} dictionary. Tha is, what happens when we call the function. Is theclass executed first without calling the add function. Thanks