title: How to return the class instance in a function in Python
body: <p>I had a class challenge this week and although I returned the correct age I did not return the class instance as per instructions.  I've read <a href="https://stackoverflow.com/questions/38840580/how-to-return-a-class-instance-in-member-function-of-a-class">this post</a> but the python 2.7 syntax seems completely different. </p>
  
  <p>Instructor's notes.</p>
  
  <blockquote>
    <p>The class is implemented correctly, and you create its instances correctly. But when you try to find the oldest dog, you return only its age, not the actual instance (as per instructions). The instance holds the information not only on the age, but also on the name. A minor comment: you call the function "oldest_dog" from inside the formatted string - this is unconventional, you'd better execute the function on the line before that and include only the calculated variable inside the formatted string.</p>
  </blockquote>
  
  <pre><code>class Dog:
  
      # constructor method
      def __init__(self, name, age):
          self.name = name
          self.age = age
  
  # three class instance declarations
  maxx = Dog("Maxx", 2)
  rex = Dog("Rex", 10)
  tito = Dog("Tito", 5)
  
  # return max age instance
  def oldest_dog(dog_list):
      return max(dog_list)
  
  # input
  dog_ages = {maxx.age, rex.age, tito.age}
  
  # I changed this as per instructor's notes.
  age = oldest_dog(dog_ages)
  print(f"The oldest dog is {age} years old.")
  </code></pre>