Welcome to the Treehouse Community
Looking to learn something new?
need 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):
Rich Zimmerman24,062 Points
class 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.