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!
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
mohan AbdulCourses Plus Student 1,453 Points
O.O.P python OK, now let's add a method named run_lap. It'll take a length argument. It should reduce the fuel_remaining
something isn't really clicking together heres second try (Steven Parker, could you please help or any one else please?) :
class RaceCar: 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, fuel_remaining, total_length, total): count = 0 self.laps = self.run_lap count = +1 self.length = self.length self.total_length = self.length * 0.125 self.total = self.length - self.fuel_remaining
class RaceCar: 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): count = 0 self.laps = run_lap count = +1 self.length = 0.125 self.length - self.fuel_remaining
Steven Parker228,001 Points
Here's a few hints:
- you won't need "count" ("laps" does that job)
- but you should create "laps" with the other instance variables, and set it to 0 there
- "length" is a parameter, not an instance variable (so no "self.length")
- you won't modify "length" , but you will use it to modify "fuel_remaining"
- make sure the fuel formula matches the instructions