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

drew mullen
drew mullen
1,555 Points

racecar.py challenge 2 - "bummer: try again"

really confused why this isnt working. can anyone advise?

racecar.py
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 * 0.125)
        self.laps += 1

3 Answers

drew mullen
drew mullen
1,555 Points

after copying and pasting into an IDE, i think there are hidden characters screwing with the white spacing. literally the code is fine and the spacing APPEARS to be fine but there are hidden characters that are failing the code.

can the devs at team treehouse please address this infuriating issue. or at the very least, give us a real error message

Steven Parker
Steven Parker
231,269 Points

I'm not sure what you mean. I copy/pasted your code just as is and it passed.

drew mullen
drew mullen
1,555 Points

Steven Parker this is from my execution after just copying and pasting. After seeing this error i removed all spacing (and from vscode i can tell its visually 2 tabs) and then retabbed, boom worked.

ive actually seen this issue before too. its probably because im using chrome os and im guessing they dont test much on chrome os yet

>>> from racecar import RaceCar
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mullendrew/git/racecar.py", line 10
    def run_lap(self, length):
                             ^
TabError: inconsistent use of tabs and spaces in indentation
Steven Parker
Steven Parker
231,269 Points

Your code looks good to me. :+1:

So I tried pasting it directly into the challenge, and it passed task 1 and task 2!

If you're getting a "false failure", I've heard that restarting your browser can help.

Dave Faliskie
Dave Faliskie
17,793 Points

looks like you just need to add the laps attribute to your class, in the init

self.laps = 0
Steven Parker
Steven Parker
231,269 Points

That's task 3, he's still on task 2. If it were task 3 the error message would be different.