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

yannis sousanis
yannis sousanis
7,199 Points

help here please!!

I dont know if Im in the right direction to solve this

racecar.py
class RaceCar:
    def __init__ (self, **kwargs):

        self.color = color
        self.fuel_remaining  = fuel_remaining
        for key, value remaining in kwargs.items():
            setattr(self, key, value)

1 Answer

Jaxon Gonzales
Jaxon Gonzales
3,562 Points

Hi Yannis!

A class is kind of like a blueprint for a custom object. And, just like a blueprint, a class has attributes that describe it. In your case, the racer class has a fuel_remaining attribute and a color attribute.

When you want something to happen when you instantiate a class you use init and, some init's have arguments that must be passed in to start the class and create custom attributes based on what the user wants.

This being said, you must ask the user for a color and fuel_remaining argument and then turn it into an attribute. This being said your code should look like:

class RaceCar
    def __init__(self, color, fuel_remaining, **kwargs):
        self.color = color
        self.fuel_remaining = fuel_remaining

        for key, value in kwargs.items():
            stator(self, key, value)

Hope this helps! If it does click the up arrow! If you need more help please let me know!

-Jaxon