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

Sahar Nasiri
Sahar Nasiri
7,454 Points

Why is it wrong to give the size this way to the Dragon class?

def init(self, **kwarges): sel.size = kwarges.get('size', 0)

2 Answers

Josh Keenan
Josh Keenan
20,315 Points

You have two typos.

def init(self, **kwargs):
 self.size = kwargs.get('size', 0)

kwarges is spelt kwargs and sel.size should be self.size.

Josh Keenan
Josh Keenan
20,315 Points

For the challenge you are doing you don't need a solution like this.

Here's mine

from monster import Monster


class Dragon(Monster):
  size = # any integer
Moosa Bonomali
Moosa Bonomali
6,297 Points

Also, If you need to instantiate your object with initial values then you need to use init def init(self, **kwargs): self.size = kwargs.get('size', 0)