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 Inheritance Inheritance Quiz

1 Answer

Steven Parker
Steven Parker
231,275 Points

You didn't mention which question you are asking about, but the one that gives most folks trouble has a class method that ends with "return has_pulp".

This example is missing the "self." prefix before the name, which is needed to reference an instance variable.

mohan Abdul
mohan Abdul
Courses Plus Student 1,453 Points

its this:

class Orange(Fruit):
    has_pulp = True

    def squeeze(self):
        return has_pulp

Orange().squeeze() will return True. (So how should it be entered to return true?)

Steven Parker
Steven Parker
231,275 Points

Yes, that's the one. The last line is the problem, fixing it (which would make the question True) would look like:

        return self.has_pulp