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!

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 trial

Python Object-Oriented Python Instant Objects Master Class

OK, now let's add a method named run_lap. It'll take a length argument. It should reduce the fuel_remaining att

I don't know what it is I'm not doing correctly, please help

class RaceCar:

    def __init__(self, color, fuel_remaining, laps=0, **kwargs):
        self.color = color
        self.fuel_remaining = fuel_remaining
        self.laps = laps

        for key, value in kwargs.items():
            setattr(self, key, value)

    def run_lap(self, length, **kwargs):
        self.fuel_remaining = fuel_remaining - (length*0.125)
        laps += 1

I think the only issue is with your 'run_lap' function. Try removing **kwargs and fuel_remaining and see if that helps. Code provided:

 def run_lap(self, length):
        self.fuel_remaining -= (length * .125)
        self.laps += 1

1 Answer

Steven Parker
Steven Parker
225,742 Points

You're close, but:

  • in "run_lap", you need to add the "self." prefix to the second reference to "fuel_remaining"
  • you need to add the "self." prefix to the reference to "laps" on the last line
  • It doesn't affect passing, but "run_lap" does not need a "**kwargs" parameter