Python len() встроенная функция
Пример
Возвращает количество элементов объекта:
>>> len('hello')
# 5
>>> len(['cat', 3, 'dog'])
# 3
Проверка на пустоту
len, а предпочтительнее прямое булево вычисление. 
>>> a = [1, 2, 3]
# bad
>>> if len(a) > 0:  # evaluates to True
...     print("the list is not empty!")
...
# the list is not empty!
# good
>>> if a: # evaluates to True
...     print("the list is not empty!")
...
# the list is not empty!