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

Shawndee Boyd
Shawndee Boyd
6,002 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
6,002 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
6,002 Points

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

Shawndee Boyd
Shawndee Boyd
6,002 Points

Thanks David and Petros!!! I got it!