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 trialKennedy Malonga
18,790 PointsTry Again
i feel like everything is right but there's something wrong
class RaceCar:
def __init__(self, color, laps = 10, fuel_remaining, **kwargs):
self.color = color
self.laps = laps
self.fuel_remaining = fuel_remaining
for key,value in kwargs.items():
setattr(self ,key , value)
def run_lap(self, length):
self.fuel_remaining += feul_remaining(length * 0.125)
self.laps -=1
red_car = RaceCar("red", 50, 0):
RaceCar.laps = 10
red_car.laps = 10
1 Answer
Chris Freeman
Treehouse Moderator 68,454 PointsHey Kennedy Malonga, a few errors to correct:
- positional arguments for
__init__
(such asfuel_remaining
) must be listed before keyword arguments (laps=10
) - a syntax error and typo "feul_remaining", and attribute reference error (missing
self.
) here:
self.fuel_remaining += feul_remaining(length * 0.125)
# should be
self.fuel_remaining += (length * 0.125)
# or
self.fuel_remaining = self.fuel_remaining - (length * 0.125)
- need to increment
self.laps
instead of decrement the attribute - the last three lines (outside of the class definition) should be deleted
Post back if you need more help. Good luck!!