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 Frustration

Sam Wederell
Sam Wederell
20,276 Points

OOP Frustration - incorrect number of parameters

Keeps saying I have the incorrect number of parameters, 0 rather than 1 or 1 rather than 0. I have typed it from scratch to make sure. Any ideas?

frustration.py
class Liar(list):

    def __len__(self):
        super().__len__(self)

2 Answers

Sam Wederell
Sam Wederell
20,276 Points

Unknown reason, suddenly decided to work. maybe page refresh?

Pierre Guiglion
Pierre Guiglion
11,583 Points

Cool! Yes that happens sometimes :)

Pierre Guiglion
Pierre Guiglion
11,583 Points

I don't think you need to repeat self when you call __len__() in super(), since it already takes any arguments that were passed to the parent class' __len__.

Try with:

def __len__(self):
    super().__len__()
Sam Wederell
Sam Wederell
20,276 Points

Trying that returns: TypeError: 'NoneType' object cannot be interpreted as an integer

Pierre Guiglion
Pierre Guiglion
11,583 Points

This code won't pass the challenge as is, because you still need to return something (whatever) that is different than the real expected length (maybe something like returning "length+1" instead of "length)

Here for the moment you are only calling len as defined in the parent class, nothing more.

Sam Wederell
Sam Wederell
20,276 Points

originally I was returning super().len()+4 but was getting the same errors. Which I've just gone back and apparently now works. Thanks for the insight.