Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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