Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
bummer expected "Meeeeeeeeeeeeeeeeeeeeeeeee" got meeeeeeeeeeeeeeeeeeeeeeee
code won't pass challenge the response l'm getting is confusing me help. thank you
from animal import Animal class Sheep(Animal): sound = "meeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" def animal_noise(self): return self.sound.lower() def Sheep_noise(self): return self.sound.uppercase()
The last step of that challenge requires you to override the
noise() method in the
Animal base class. You do that by defining a method with the exact same name in the
Sheep class. The code should look like the following:
from animal import Animal class Sheep(Animal): sound = "meeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" # let's re-define the noise method and override the # implementation from the base class def noise(self): # we need to transform the "sound" instance var into it's upper-case version return self.sound.upper()
Note that in order to transform a string into its uppercased counterpart you need to call the
upper() method on it.
Hope this helps.
Dan Johnson40,532 Points
In order to override a method of the base class, it needs to have the same name in the child class:
def noise(self): return self.sound.upper()