Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Confusion in code
class Inventory: def init(self): self.slots = 
def add(self, item): self.slots.append(item) def __len__(self): return len(self.slots) def __contains__(self, item): return item in self.slots def __iter__(self): yield from self.slots
Where does self.slots comes from, it was not defined inside init method. any suggetion will be appreciated ?
Jake Kobs9,215 Points
In the init method, since slots isn't being passed within the parameters, it's automatically being assigned to an empty list. Therefore, slots is being created in the init method.