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 Advanced Objects Dream Car

In the method, return a string that states the dream car's make and model

I cannot get this one,

dream_car.py
class DreamCar:
    def __init__(self, make, model):
        self.make = make
        self.model = model
    # insert your code here
    def __str__(self):
       return"My car {} {}".format(self.make, self.model)

4 Answers

Steven Parker
Steven Parker
231,248 Points

The instructions ask for output that looks like "My dream car is a {make} {model}.", but this code would output a string like "My car {make} {model}" instead.

But I wasn't able to get it to work even with a corrected string. It seems like there might be a bug in challenge's handling of the "format" function. If you have the same issue, you might want to submit a bug report as described on the Support page (you might get an "Exterminator" :beetle: badge!)

But I was able to make it pass using "f-string" formatting:

        return f"My dream car is a {self.make} {self.model}."

Manuel,

This should work.

class DreamCar:
    def __init__(self, make, model):
        self.make = make
        self.model = model
    # insert your code here
    def __str__(self):
        return f'My dream car is a {self.make} {self.model}.'

Thanks Steven

Manuel Canario
Manuel Canario
1,458 Points

I am stock, the program sitll ask function should only take self argument?

class DreamCar: def init(self, make, model): self.make = make self.model = model # insert your code here def str(self, make, model): return "My dream car is a {} {}".format(self.make, self.model)

File "", line 40, in test_function_code AssertionError: 1 != 3 : Your function should only take the self argument