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 (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??

method.py
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
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
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: