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 Instant Objects Master Class

Confused

I am confused. Can someone explain to me what I am doing wrong please.

racecar.py
class RaceCar(color, fuel_remaining):
    def __init__(self, color, fuel_remaining, **kawargs):
        self.color = red
        self.fuel_remaining = guage
        for key, value in kwargs.items():
            setattr(key, value, **kwargs)
Dave StSomeWhere
Dave StSomeWhere
19,870 Points

Check out the teachers notes on the Method Arguments video and compare it to your code.

Here's 4 things that look wrong - is that what you are asking about?

  1. Looks like the spelling of kwargs isn't consistent
  2. Assignment of self.color and self.fuel_remaining is not being set with the parameter values
  3. Why are you passing **kwargs to setattr()? You're already passing the key and value, also don't you need self in there?
  4. Are you sure you want to have parameters in the class definition.

2 Answers

Steven Parker
Steven Parker
231,248 Points

You're getting kind of close, but:

  • "RaceCar" doesn't inherit from other classes, so it doesn't need terms in parentheses
  • you have "kawargs" (with an extra "a") instead of "kwargs"
  • nothing named "red" has been defined .. did you mean "color"?
  • nothing named "guage" has been defined ... did you mean "fuel_remaining"?
  • the "setattr" function doesn't need a "**kwargs" argument
  • but it does need a "self" argument