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 trialBrent Liang
Courses Plus Student 2,944 PointsBummer
The question specifies that keywords should be passed to .format() if the placeholders have names, what does it mean and what's wrong with the following code?
class Store:
open = 9
close = 16
def hours():
return "We're open from {} to {}.".format(open,close)
Steven Parker
231,271 PointsThis challenge specifically asks you to use open as a variable name.
Brent Liang
Courses Plus Student 2,944 PointsThank you evgenypanov!!
I love your code and it definitely shows how important the "self" parameter is.
Sorry I have to give the best answer to Steven, would've chosen yours!! :)
1 Answer
Steven Parker
231,271 PointsYou forgot to include "self" as the method parameter.
You'll also need to use it as a prefix for the class variables in the format.
You might want to review the video on Class Methods.
Brent Liang
Courses Plus Student 2,944 PointsThank you Steven!!! It works.
evgenypanov
1,521 Pointsevgenypanov
1,521 Points1) Don't use built-in functions name like that open() as a variable name. 2) All methods in class must have 'self' as the first argument. 3) Best way to init variables in class, use special method init. This method runs when you create instances of class every time.
Your code may be like that.