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

Scott Jones
Scott Jones
5,397 Points

.Orange().squeeze() == false

Quiz Question 3 of 5 "

class Orange(Fruit):
    has_pulp = True

    def squeeze(self):
        return has_pulp

Orange().squeeze() will return True. "

The quiz says this is false. I don't understand why. Any insight would be much appreciated :)

3 Answers

Steven Parker
Steven Parker
231,268 Points

The "squeeze" method is not coded correctly.

When referencing a class property, the name must be prefixed with "self.", which was not done here. Based on the code shown, the global "has_pulp" being referenced here may not be defined, or if it is, it's value is unknown.

aditya yadav
aditya yadav
1,505 Points

Also Fruit class is undefined

Steven Parker
Steven Parker
231,268 Points

For the purpose of the quiz question, I think you're supposed to assume that Fruit is defined elsewhere.

Scott Jones
Scott Jones
5,397 Points

I was totally overlooking the syntax. I thought I was missing some concept on parent classes. Thanks lol

Scott Jones
Scott Jones
5,397 Points

Oops. firstpost thanks again!