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 (retired) Inheritance Override Inherited Methods

FHATUWANI Dondry MUVHANGO
FHATUWANI Dondry MUVHANGO
17,796 Points

problems with Sheep.py

i always get "try again", am i missing something?

sheep.py
from animal import Animal

class Sheep(Animal):
    def __init__(self, sound):
        sound = 'meeh'
    def noice(self):
        return self.sound.upper()

8 Answers

Hi Fhatuwani,

Your updated code has class at the end of the first line but you don't need that.

The instructions don't request an __init__ method so you should not have that in there. For task 2 you only need to set the sound attribute to something other than "Roar".

This is what you should have had by the end of task 2: (the string could be different)

from animal import Animal

class Sheep(Animal):
    sound = "bah"

For the noise method you still have a typo. You have noice and it should be noise

Try this:

from animal import Animal

class Sheep(Animal):
    def __init__(self, sound):
        self.sound = sound

    def noise(self):
        return self.sound.upper()

Here was the errors:

  • You misspelled noise
  • You forgot to use self in the __init__ method (you did sound instead of self.sound)
  • You were supposed to set self.sound to the argument sound

The code above is the complete code :)

Good luck! ~alex

I believe the only issue with your code is that a function name does not match the instructions. Go through carefully and double-check your spelling (use the code-challenge instructions to compare).

Actually, he had a problem in the __init__ method too :)

FHATUWANI Dondry MUVHANGO
FHATUWANI Dondry MUVHANGO
17,796 Points

hey Alex , i wrote that script(changed 'meeh' to 'sound') and it doesnt work it keeps say "try again"

and Nate, i followed the question and i am pretty sure i've used all the words correctly, i dont know what the task is asking from me now

Try copy-pasting my code

If that doesn't work, then please provide the task's question so I can really understand :)

~alex

FHATUWANI Dondry MUVHANGO
FHATUWANI Dondry MUVHANGO
17,796 Points

Animal.noise() returns self.sound.lower(). Make Sheep.noise() return the uppercased version of the instance's sound.

this is the question

FHATUWANI Dondry MUVHANGO
FHATUWANI Dondry MUVHANGO
17,796 Points

this is what it says when i try ' from animal import Animal class': "It looks like Task 1 is no longer passing."

FHATUWANI Dondry MUVHANGO
FHATUWANI Dondry MUVHANGO
17,796 Points
from animal import Animal class

class Sheep(Animal):
    def __init__(self, sound):
        self.sound = sound

    def noice(self):
        return self.sound.upper()

i've tried this, but its still not correct

fixed code formatting