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

Make a new class named Sheep that inherits from Animal. The Animal class is in animal.py. Remember, you can use pass to

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.

sheep.py
import  animal (animal.py): class Sheep(Animal), pass

I think you're really close. For the import, I believe it should look like from animal (py file) import Animal (class) for the class creation, you are maybe just off by a :

Thanks but still Facing Challenges. Any Help.

that one worked for me

4 Answers

Vittorio Somaschini
Vittorio Somaschini
33,371 Points

Hello!

There is a bit of confusion in your code I believe. Let's tackle it step by step:

1) the import statement >> from the file animal.py we want to import the class Animal, so:

from animal import Animal

2) the class definition: your code is close but after class Sheep(Animal) you need to use ":" instead of the comma you used. It will look like this:

class Sheep(Animal):
    pass

This should work fine.

Vittorio

Hi, Vittorio.

Thank you for the help. It has passed:

from animal import Animal class Sheep(Animal): pass

Casey Huckel
PLUS
Casey Huckel
Courses Plus Student 4,257 Points

from animal import Animal class Sheep(Animal): Pass

Didn't work for me. I got "Pass" is not defined

pass is lowercase

from animal import Animal class Sheep(Animal): pass