You already know __init__ and __str__. These are called special methods (or dunder methods — double underscore). Python has many more! They let your objects work with operators like +, ==, <, and even len().
For example, when you write len([1,2,3]), Python actually calls the list's __len__ method. Let's make our objects work the same way!
↗️
Loading editor...
↶
↷
By defining __len__, we can use len() on our own objects! Python translates len(team) into team.__len__().