Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Object-Oriented Python Advanced Objects Emulating Built-ins

Maximilian Tan
Maximilian Tan
5,570 Points

'Inventory' object is not iterable

I followed the code as explained in the video however I got an error ''Inventory' object is not iterable'.

Can anyone enlighten me on what possibly went wrong?

cheers!

Pitrov Secondary
Pitrov Secondary
5,121 Points

Could you show us your code. I had the same problem, but figured that in line 15 - 16 you need to do:

    def __iter__(self):
        yield from self.slots

and not

    def __iter__(self):
        for item in self.slots:
            yield item

1 Answer

I faced the same error even with the proper code, so I took a chance and restarted Workspaces, which ended up fixing the problem. You've almost certainly resolved this, but just for anyone else who stumbles across the error.