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

Overwrite inherited methods

Make a new class named Sheep that inherits from Animal. The Animal class is in animal.py. Remember, you can use pass to make empty classes. Whats the strategy guys ?

sheep.py
class Sheep(Animal):
  from animal.py import Animal
    Animal_class="sheep"
  pass

2 Answers

Ryan Ruscett
Ryan Ruscett
23,309 Points

Not sure I understand what you are getting at. Imports always go at the top. At least in this exercise they should. You also don't need to include the py in animal. You also have Animal_class("Sheep"). Not sure why you did that. You also only have half the challenge done. If you do the challenge as it is expected and to the end. It all comes together a lot more clearly.

from animal import Animal

class Sheep(Animal):
  sound = "rrrr"

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

from animal.py import Animal
class Sheep(Animal): pass