len(s)

Returns the length (the number of items) of an object. The argument may be a sequence (string, tuple or list) or a mapping (dictionary).

To make this function work on your own classes, implement the __len__ method.