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 trialDhruv Ghulati
1,582 PointsWhy can I not override Animal.noise just like I override Animal.sound, via creating a new method in the class to overide
Is there a reason why def noise(self) here is not working? def sound(self) did work in its override...
from animal import Animal
class Sheep(Animal):
pass
def sound(self):
self.sound='BLaaa'
def noise(self):
self.noise=self.sound.upper()
1 Answer
Kenneth Love
Treehouse Guest TeacherYou should be changing the sound
attribute in the class, not providing a sound()
method (that that passes shows me I need to add another check to the challenge. Thanks for finding that!). Finally, in noise()
, you need to return the uppercased version of the sound. What you're doing now is changing the method to an attribute...sorta. It's just erroring out due to that being invalid code.
Dhruv Ghulati
1,582 PointsDhruv Ghulati
1,582 PointsThanks. This helped and I completed the challenge :)