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 trial

Python Object-Oriented Python Instant Objects Master Class

plz tell me what's going wrong

plz help me and tell me what's the thing which is going wrong in my code

racecar.py
class RaceCar:
    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, lenght):
            lap = 0
            self.fuel_remaining -= lenght * 0.125
            self.laps += 1

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! I feel like you're doing pretty well except that you might not be understanding where to put the laps property. Also note, that you have a lap variable instead of a laps variable. This should be declared before the init and run_lap. Every time we make a new RaceCar we want to set the laps to zero by default. It's brand new! Of course it hasn't run any laps yet :smiley:

But what about the fuel_remaining? Why do we send that in? I'm guessing we do this because not every race car is the same make and model. They (even at full tanks) hold differing amounts of fuel.

Finally, the lap = 0 should be removed from the run_lap method. Otherwise, the race car will only ever show to have run one lap as the count is being reset to zero every time.

Hope this helps, but let me know if you're still stuck! :sparkles:

jopapadaki
jopapadaki
7,311 Points

Also there is a typo, check length :-)