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 trialWes Witherell
258 PointsStuck on a python question. Could someone direct me in the correct direction?
The question 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.
Should I create a str variable to put "We're open from {} to {}." or am I allowed to write that next to the return?
class Store:
open = 5
close = 7
def hours(self):
return self.
2 Answers
Chase Frankenfeld
6,137 PointsHey Wes.
You are able to write the string as:
return "We're .."
Give it a go, using .format() to input the attributes into the string. Remember, you use the self. to refer to the attribute within the class.
If you still need further help. I'll lead you in the right direction.
Gloria Dwomoh
13,116 PointsBoth are allowed, so that is up to you. Maybe try both.