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 trialSam Wederell
20,276 PointsOOP 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?
class Liar(list):
def __len__(self):
super().__len__(self)
2 Answers
Sam Wederell
20,276 PointsUnknown reason, suddenly decided to work. maybe page refresh?
Pierre Guiglion
11,583 PointsI 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
20,276 PointsTrying that returns: TypeError: 'NoneType' object cannot be interpreted as an integer
Pierre Guiglion
11,583 PointsThis 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
20,276 Pointsoriginally 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.
Pierre Guiglion
11,583 PointsPierre Guiglion
11,583 PointsCool! Yes that happens sometimes :)