Python Object-Oriented Python Advanced Objects Frustration

Sam Wederell
Sam Wederell
16,040 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
16,040 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
16,040 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
16,040 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.