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 trialERDAL DINCER
1,635 PointsChallenge Task 2 in Classes I don't know why it is not running
class RaceCar: laps=0 def init(self, color, fuel_remaining, **kwargs): self.color = color self.fuel_remaining = fuel_remaining self.dict.update(kwargs) def run_lap(self,length): self.lenght=lenght laps=laps+1 return fuel_remaining-(self.lenght*0.125)
class RaceCar:
laps=0
def __init__(self, color, fuel_remaining, **kwargs):
self.color = color
self.fuel_remaining = fuel_remaining
self.__dict__.update(kwargs)
def run_lap(self,length):
self.lenght=lenght
laps=laps+1
return fuel_remaining-(self.lenght*0.125)
1 Answer
Steven Parker
231,269 PointsI see a few issues:
- "length" is spelled "lenght" in 3 places
- "length" is a parameter so it will not use the "self." prefix
- but "fuel_remaining" does need the "self." prefix
- the function should change the value of "fuel_remaining"
- the function doesn't need to "return" anything