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

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

Object Oriented Python - Cannot pass challenge - class RaceCar

The challenge (step 2 of 3) asks:


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

Oh, and add a laps attribute to the class, set to 0, and increment it each time the run_lap method is called.

The init function was done is step 1 and passed.

I added the laps attribute line to the init function.

Here's my code and it appears to test fine locally for executing the run_lap() method. The challenge just says Bummer, Try Again - no clue as to what failed.

class RaceCar:

    def __init__(self, color, fuel_remaining, **kwargs):
        self.laps = 0
        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 * 0.125
        self.laps += 1

1 Answer

Jason Anders
Jason Anders
Treehouse Moderator 145,857 Points

Hi Dave,

Your code looks fine!

There may have been a temporary glitch in the challenge (this does happen occasionally).

Restart the challenge and copy/paste the code snippet you have above into a fresh challenge and it will all pass (it did for me).

Nice work!! :) :dizzy:

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

Thanks, Jason it worked - things were flaky earlier today were sometimes the embedded code in the teachers notes and challenges did not show up.