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 trialAizah Sadiq
2,435 PointsRacecar challenge part 1
Can someone give me a hint or some guidance for where I am going wrong.
Class RaceCar:
def __init__(self, color, fuel_remaining,**kwargs):
self.color = color
self.fuel_remaining = fuel remaining
for self, key, value in kwargs.items():
setattr (self, key, value)
3 Answers
Steven Parker
231,275 PointsVery close! But:
- like most Python keywords, "class" should be all lower case
- "fuel remaining" should be "fuel_remaining" (underscore instead of space)
- the "items" method returns only keys and values (no "self")
Aizah Sadiq
2,435 PointsWhat is wrong here?
class RaceCar:
def __init__(self, color, fuel_remaining,**kwargs):
self.color = color
self.fuel_remaining = fuel_remaining
for self, key, value in kwargs.items():
settattr(key, value)
Aizah Sadiq
2,435 PointsIt is still not running
class RaceCar:
def __init__(self, color, fuel_remaining, **kwargs):
self.color = color
self.fuel_remaining = fuel_remaining
for key, value in kwargs.items():
setattr(key, value)
```
Steven Parker
231,275 PointsBut you do need "self" in the "setattr" call:
setattr(self, key, value)
Steven Parker
231,275 PointsSteven Parker
231,275 PointsOn that third hint, the correction would look like this (with no "self"):
for key, value in kwargs.items():