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

Shane Smith
seal-mask
.a{fill-rule:evenodd;}techdegree
Shane Smith
Python Development Techdegree Student 2,550 Points

What 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!

racecar.py
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
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi 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 :smiley: 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! :sparkles:

Shane Smith
seal-mask
.a{fill-rule:evenodd;}techdegree
Shane Smith
Python Development Techdegree Student 2,550 Points

Thank you for the assistance Jennifer but I am still not there...

this is what I have now

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 * .125
        laps += 1