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 trialellie adam
26,377 PointsAdd Method hours
class Store: open = 9 close = 8
def hours(hours): return.hours("We're open from 9 am to 8 pm.")
OR def hours(hours): return.format("We're open from 9 am to 8 pm.")
I get error.
class Store:
open = 9
close = 8
def hours(hours):
return.hours("We're open from 9 am to 8 pm.")
OR
def hours(hours):
return.format("We're open from 9 am to 8 pm.")
1 Answer
Guled Ahmed
12,806 PointsHello Ellie,
Remember that your hours method needs to have the self parameter. The reason for this is because when an instance ( or a Shop object in this case) calls on the hours method, this will ensure that that object is calling on the hours method. After doing that you simply return a string then use the dot notation to access the format method. You need to then pass in the objects open and close properties into the format method. The final result should look like this:
class Store:
open = 9
close = 8
def hours(self):
return "We're open from {} to {}.".format(self.open, self.close)