A Methodical Approach


#1

This won’t print the description. Any tips please?

class Animal(object):
  """Makes cute animals."""
  is_alive = True
  def __init__(self, name, age):
    self.name = name
    self.age = age
    
def description(self):
  print self.name
  print self.age
  
hippo = Animal("Ben", 7)

print hippo.description()

#2

Hi @coldweb,

The entire description method definition needs to be indented in order for it to be part of the Animal class definition.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.