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 trialShane Smith
Python Development Techdegree Student 2,550 PointsWhat am I missing?!?
The preview code function is just saying "bummer try again" and not throwing an error so I am unsure of where my mistake is. Thank you in advance!
class RaceCar:
laps = 0
def __init__(self, color, fuel_reamaining, **kwargs):
self.color = color
self.fuel_remaining = fuel_reamaining
for key, value in kwargs.items():
setattr(self, key, value)
def run_lap(self, length):
self.length = length
fuel_remaining = fuel_remaining - (self.length * .125)
laps += 1
1 Answer
Jennifer Nordell
Treehouse TeacherHi there, Shane Smith! The issue here is that fuel_remaining
is undefined. It doesn't exist in the context of that method. What you're looking for is self.fuel_remaining
Also, you do not need to make a new attribute named self.length
. We're passing in the length to the method so you could do self.fuel_remaining -= length * .125
.
Hope this helps!
Shane Smith
Python Development Techdegree Student 2,550 PointsShane Smith
Python Development Techdegree Student 2,550 PointsThank you for the assistance Jennifer but I am still not there...
this is what I have now
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherHi there, Shane Smith! You will also need
self.laps
as opposed to justlaps += 1
Shane Smith
Python Development Techdegree Student 2,550 PointsShane Smith
Python Development Techdegree Student 2,550 PointsIts always the simple errors :( Thank you very much!