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 Subclass

David Bell
David Bell
16,997 Points

Is there more to the subclass challenge that I'm not understanding?

I feel like my answer addresses the challenge, but I'm not certain what I'm actually missing, based on the question. My code is attached.

The error I get is a TypeError, stating that init only takes 2 values, and I'm trying to pass 3, which I don't see that I'm doing. Do I, unlike the video example, need to set an init for Dragon? What am I missing?

my_monster.py
import monster

class Dragon(monster):
  size = 10

1 Answer

David Bell
David Bell
16,997 Points

Gurgle. Learning moment:

The import syntax is exactly wrong. Should be:

from monster import Monster

not the other way around. Not like the random import, different because its a user generated file, it seems.

Nothing to see here. :)

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

It's not the creation of the file (user vs built-in) that matters, but what we want from the file. Before, we asked for the entire random library. Now, though, we only want a single class, Monster, from our monster library. This is just like doing from random import randint.

David Bell
David Bell
16,997 Points

I see! Thank you!