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

Jorge Grajeda
seal-mask
.a{fill-rule:evenodd;}techdegree
Jorge Grajeda
Python Development Techdegree Student 4,983 Points

Master Class Help

It says try again but not specifying what is incorrect here, can somebody please help me out? :)

racecar.py
class RaceCar:
    def __init__(self, color, fuel_remaining, laps = 10, **kwargs):
        self.color = color
        self.laps = laps
        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

red_car = RaceCar("red", 50, 0):
    RaceCar.laps = 10
    red_car.laps = 10

4 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

Hey Jorge Grajeda, you are SO close!

The laps attribute should be set to 0, not to 10.

Post back if you need more help. Good luck!!!

Jorge Grajeda
seal-mask
.a{fill-rule:evenodd;}techdegree
Jorge Grajeda
Python Development Techdegree Student 4,983 Points
class RaceCar:
    def __init__(self, color, fuel_remaining, laps = 0, **kwargs):
        self.color = color
        self.laps = laps
        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 += 0

red_car = RaceCar("red", 50, 0):
    RaceCar.laps = 10
    red_car.laps = 10
Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

Delete

red_car = RaceCar("red", 50, 0):
    RaceCar.laps = 10
    red_car.laps = 10