The first example,
len() is a function that takes an object.
The second example is a string method,
str.lower() that will only work on string objects.
In other words, the len() function is not dedicated to any particular class of objects. We can use it on strings and lists in the exact same way.
str is a class of objects to which all strings belong. The method is a function of the class, and can only be accessed by string objects.
lower() is said to be an attribute of the string object, as signified by the dot notation.
The concept of
class will arise later in the course, so don't trouble yourself too much with studying this concept, just now. It is sufficient to know that all object in Python belong to a particular class. Strings are members of the
str class; lists are members of the
list class; dictionaries are members of the
dict class; integers are members of the
int class; floats are members of the
float class, and so on. It will begin to make more sense as you progress.