Can a class inherit from more than one base class?



In this exercise, a standalone class exists as well as another class that inherits from it. Is it possible to inherit from more than one class?


Yes, a class can inherit from more than one base class. The term for this is “multiple inheritance”. When inheriting from a single class, the base class is included in parenthesis as part of the class definition following the class name. To inherit from additional base classes, classes are added into the definition separated by commas. An example of multiple inheritance is shown in the code below.

class A:

class B:

class C(A,B):