Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

ilya A
3,802 Pointsneed help on master class (challenge task 1 of 3)
I am getting an error: "Bummer! Try again!"
class RaceCar:
__init__ = "color", "fuel_remaining"
def setattr(self.RaceCar):
1 Answer

Rich Zimmerman
24,062 Pointsclass RaceCar:
def __init__(self, color, fuel_remaining, **kwargs):
self.color = color
self.fuel_remaining = fuel_remaining
for key, value in kwargs.items():
setattr(self, key, value)
the init function sets the variables of the class when instantiated, keep in mind that creating a class like this is just defining the class's methods and properties. It's not actually being USED yet.
so when instantiating a RaceCar class, you would do something like this
my_car = RaceCar('black', 50)
print(my_car.color)
# prints "black"
print(my_car.fuel_remaining)
# would print 50
and kwargs are optional for any other key : value pairs passed as parameters when you create a new instance of the class.