8. Methodical Approach


I got the correct code for this excercise but i was wondering if someone could please explain why we dont add name, age as arguements for the description function
code is as follows:

class Animal(object):
    """Makes cute animals."""
    is_alive = True
    def __init__(self, name, age):
        self.name = name
        self.age = age
    # Add your method here!
    def description(self): #why dont we add name and age
        print self.name 
        print self.age 
hippo = Animal("Yeezy", 20)

thanks in advance


The self argument gives the function access to other descriptors. By using self, (dot notation) then it knows all your attributes.