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.

Python Object-Oriented Python (retired) Inheritance Override Inherited Methods

Shawndee Boyd
Shawndee Boyd
5,917 Points

Challenge 3 of 3: I am thinking that this code would return sound.upper but obviously I am wrong. Can someone help me?

from animal import Animal

class Sheep(Animal):
  sound = 'squak'

  def noise(Animal):
    self.sound()

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

6 Answers

David Bouchare
David Bouchare
9,224 Points

Hey,

so like Petros mentioned above, you shouldn't have Sheep as a second argument of your noise method. Remove it and it should work (Sheep is a class, not an argument of a method).

from animal import Animal

class Sheep(Animal):
  sound = 'squak'

def noise(self):
  return self.sound.upper()
Petros Sordinas
Petros Sordinas
16,181 Points

Hi Shawndee,

Yes you should return sound.upper(), however you have some mistakes in your code:

  • You don't need to define noise(Animal)
  • You need to define noise in Sheep and pass (self) in the method arguments and then return self.upper()
David Bouchare
David Bouchare
9,224 Points

Also, if you could please format your code, that would greatly help. Using the Markdown Cheatsheet below for instance.

Shawndee Boyd
Shawndee Boyd
5,917 Points

'''from animal import Animal

class Sheep(Animal): sound = "Squak"

def noise(self, Sheep): return self.sound.upper()'''

This is the code that I have but this is not working either. I am obviously misinterpreting something.

Shawndee Boyd
Shawndee Boyd
5,917 Points

Also, sorry about the post. I forgot the markdown.

Shawndee Boyd
Shawndee Boyd
5,917 Points

Thanks David and Petros!!! I got it!