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 trialjessicakincaid
21,834 PointsStruggling with Part 2 of the RaceCar Challenge. Could someone share a hint?
The instructions require that we iterate through the number of laps. Should I use self.fuel_remaining in the run_lap method? This is the for loop I put inside the method, using self and length as arguments:
def run_lap(self, length, laps):
laps = 0
self.fuel_remaining = self.fuel_remaining - self.length * 0.125
laps += 1
3 Answers
Steven Parker
231,275 PointsIt looks like you've gotten a bit off track. No, you don't need a loop since "run_lap" always adds just one lap. But you also have some main class issues:
- the name should not be set to a static value, use the passed argument
- the color should also not be set to a static value, use the passed argument
- same thing with fuel_remaining, use the argument
- "laps" should not be an argument, it is always set to a static value (0)
- "length" should not be an argument OR a class attribute, it's only used in "run_lap"
- none of the arguments need defaults
And the original code for "run_lap":
- should not take "laps" as an argument
- should not set "laps" to 0
- should reference "laps" using a "self." prefix
- should not use "self." on the argument "length"
jessicakincaid
21,834 PointsThank you so much for reviewing my code. This should help me eliminate a lot of issues.
jessicakincaid
21,834 PointsOh wow! It took so long but I got it after lots of trial and error. Thank you.