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
Saghir Hussain
8,765 PointsStuck on Object-Oriented Python Task 2 of 2
The task is: Now, add a method named hours that returns "We're open from {} to {}.". Replace the first placeholder with the open time and the second with the close time. Remember you need to pass keywords to .format() if your placeholders have names.
My code is:
class Store:
open = 9
close = 17
def hours(self):
return self."We're open from {} to {}".format(open, close)
but some reason it says that task 1 is no longer passing. Can someone help.
Thanks
2 Answers
Dan Johnson
40,533 PointsYou won't need to use self on a string literal, but you will need to use it on properties of the class. open and close in this case, in the hours method.
Saghir Hussain
8,765 PointsAh yes...thanks mate!
Dan Johnson
40,533 PointsDan Johnson
40,533 PointsAdded code tags.