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 trialKyle Petran
5,017 PointsNot sure what I'm doing wrong, I'm guessing it has something to do with initializing the laps attribute?
I am somewhat confused about adding the attribute laps, I tried it in and out of init, nothing has seemed to work.
class RaceCar:
def __init__(self, color, fuel_remaining, **kwargs):
self.color = color
self.fuel_remaining = fuel_remaining
self.laps = 0
for key, value in kwargs.items():
setattr(self, key, value)
def run_lap(self, length):
self.fuel_remaining -= length * .125
self.laps += 1
1 Answer
Steven Parker
231,248 PointsThis looks OK to me, so I copied and pasted it directly into the challenge and it passed all 3 tasks.
Try again?
Kyle Petran
5,017 PointsKyle Petran
5,017 PointsI think it's just bugged. I copied in another users solution and it worked for whatever reason. All that was changed was this line
'''self.fuel_remaining -= length * .125'''
became ''' self.fuel_remaining = self.fuel_remaining - length * .125'''
I don't know why that would make it work, but just to be clear you think my original solution would have worked?
Steven Parker
231,248 PointsSteven Parker
231,248 PointsI don't just think it would, I actually pasted it into the challenge and it did work.
You might want to report the bug to the Support folks.