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 trialKent Utomo
652 Pointsi can't answer this question.
unable to answer this question.
class Store:
open = 9
close = 10
1 Answer
Kenneth Love
Treehouse Guest TeacherA method is a function that belongs to a class. We know it belongs to the class because it's indented under the class. Like:
class Book:
current_page = 0
def read_page(self):
self.current_page += 1
Methods also always take the argument self
, which represents an instance of the class.
my_book = Book()
my_book.read_page()
On the second line above, when read_page
is executed, both self
s refer to my_book
, not Book
.
So you need to add a method to your Store
class. What's your first step for that?