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 trialJorge Grajeda
Python Development Techdegree Graduate 8,186 PointsMaster Class Help
It says try again but not specifying what is incorrect here, can somebody please help me out? :)
class RaceCar:
def __init__(self, color, fuel_remaining, laps = 10, **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 -= (length * 0.125)
self.laps += 1
red_car = RaceCar("red", 50, 0):
RaceCar.laps = 10
red_car.laps = 10
4 Answers
Chris Freeman
Treehouse Moderator 68,457 PointsHey Jorge Grajeda, you are SO close!
The laps
attribute should be set to 0, not to 10.
Post back if you need more help. Good luck!!!
Jorge Grajeda
Python Development Techdegree Graduate 8,186 Pointsclass RaceCar:
def __init__(self, color, fuel_remaining, laps = 0, **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 -= (length * 0.125)
self.laps += 0
red_car = RaceCar("red", 50, 0):
RaceCar.laps = 10
red_car.laps = 10
Chris Freeman
Treehouse Moderator 68,457 PointsThe self.laps += 1
should not have changed.
Also, the line creating an instance and defining red_car
needs to be deleted.
Otherwise, itβs good.
Jorge Grajeda
Python Development Techdegree Graduate 8,186 PointsCould you be a little more specific or maybe show me what you mean by the instance defining red_car needs to be deleted?
Chris Freeman
Treehouse Moderator 68,457 PointsDelete
red_car = RaceCar("red", 50, 0):
RaceCar.laps = 10
red_car.laps = 10
Jorge Grajeda
Python Development Techdegree Graduate 8,186 PointsOhhhhh okay thank you so much! :D