Have you ever had multiple classes that have similar attributes and methods? If so, use inheritance to organize your classes.
Inheritance allows us to define a parent class and child classes. A child class inherits all the methods and attributes of the parent class.
In the code above, we define the parent class to be Dog
and the child classes to be Dachshund
and Poodle
. With class inheritance, we avoid repeating the same piece of code multiple times.