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 trialFHATUWANI Dondry MUVHANGO
17,796 Pointsproblems with Sheep.py
i always get "try again", am i missing something?
from animal import Animal
class Sheep(Animal):
def __init__(self, sound):
sound = 'meeh'
def noice(self):
return self.sound.upper()
8 Answers
Jason Anello
Courses Plus Student 94,610 PointsHi 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
Alexander Davison
65,469 PointsTry 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 didsound
instead ofself.sound
) - You were supposed to set
self.sound
to the argumentsound
The code above is the complete code :)
Good luck! ~alex
Nate Sturgeon
2,255 PointsI 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).
Alexander Davison
65,469 PointsActually, he had a problem in the __init__
method too :)
FHATUWANI Dondry MUVHANGO
17,796 Pointshey 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
Alexander Davison
65,469 PointsTry 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
17,796 PointsAnimal.noise() returns self.sound.lower(). Make Sheep.noise() return the uppercased version of the instance's sound.
this is the question
FHATUWANI Dondry MUVHANGO
17,796 Pointsthis is what it says when i try ' from animal import Animal class': "It looks like Task 1 is no longer passing."
FHATUWANI Dondry MUVHANGO
17,796 Pointsfrom 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
Jason Anello
Courses Plus Student 94,610 Pointsfixed code formatting
FHATUWANI Dondry MUVHANGO
17,796 Pointsthanks Jason, i finally got it right