Joshua Hovden2,979 Points
I don't understand why Orange().squeeze() wouldn't return True
Don't Orange objects have the has_pulp attirbute equal to True and doesn't the squeeze method return has_pulp?
has_pulp is being returned through the
squeeze function but is an attribute outside of the
class Orange: has_pulp = True def squeeze(self): return has_pulp >>> Orange().squeeze() #Traceback #NameError: name 'has_pulp' is not defined
class Orange: def squeeze(self): has_pulp = True return has_pulp >>> Orange().squeeze() True
Ran into the same issue on this problem and took me a while to figure out
From testing it there is a missing
self on the
has_pulp in the
To get the code running correctly make the following change to the original code:
class Orange(Fruit): has_pulp = True def squeeze(self): return self.has_pulp
Then run the python repl and see if that works.