Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Object-Oriented Python (retired) Objects Create a Class with a Method

Syed Hassan
Syed Hassan
236 Points

I dont understand what you mean by defining the "hour" method

I am stuck in this position. How else do you define a method??

class Store:
    open = 9
    close = 10
    def hours(self):
        return self.format("We're open from {self.open} to {self.close}")

1 Answer

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Hi there! The error you're receiving is a bit misleading. You have defined the function. The problem lies in your formatting of the string you're returning. Also, your string is missing a full stop at the end. So let's see if you can get this with just a hint. Here's an example of string interpolation:

x = 10
y = 20
print("The value of x is {}.  The value of y is {}.".format(x,y))

Now, try adjusting the string you're returning to look more like the code above. Hope this helps! :sparkles: