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 trialAbdulkadir Kollere
1,723 PointsClass method is not passing
The method hours works in workspaces. If I try it in the challenge however, it gives the error "Try again". I know it something tiny that I cannot figure out which is causing this issue. Kindly assist me.
class Store:
open = 9
close = 12
def hours(self, open, close):
return ("We're open from {} to {}.".format(open, close))
2 Answers
Stuart Wright
41,120 PointsMy object oriented Python is pretty rusty so I can't give a detailed explanation for this, but with a bit of trial and error I was able to get this to pass the challenge.
You only need to pass 'self' to the function, not open and close. Then you format the string with self.open and self.close, rather than just open and close.
Stuart Wright
41,120 PointsIn your more recent attempt you are printing when it asks you to return. I believe the rest is correct.
Abdulkadir Kollere
1,723 PointsAbdulkadir Kollere
1,723 PointsI gave that a try and it did not work. See the code below: