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 trialvictor E
19,146 Pointsusing a method, not sure what I am missing here
I think I should add self somewhere here. Not sure where, can you provide a simple explanation as to when to add self and when not to add self?
class RaceCar:
laps = 0
def __init__(self, color, fuel_remaining, **kwargs):
self.color = color
self.fuel_remaining = fuel_remaining
for key, value in kwargs.items():
setattr(self, key, value)
def run_lap(self,length):
self.length = length
return fuel_remaining -= (self.length * 0.125)
return laps += 1
1 Answer
Jassim Alhatem
20,883 PointsYou're doing too much here mate. And for some reason, you have two return statements when the question didn't even ask you to return anything (return statements can only be called once).
class RaceCar:
laps = 0
def __init__(self, color, fuel_remaining, **kwargs):
self.color = color
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
victor E
19,146 Pointsvictor E
19,146 Pointsthank you, I must have been over thinking it.