Learn
When a class has its own functions, those functions are called methods. You’ve already seen one such method: __init__()
. But you can also define your own methods!
Instructions
1.
Add a method, description
, to your Animal
class. Using two separate print
statements, it should print out the name
and age
of the animal it’s called on. Then, create an instance of Animal
, hippo
(with whatever name and age you like), and call its description
method.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.