Len (programming) - Use in Python

Use in Python

In Python, len can be used to denote the length of a string:

>>> something = 'Wikipedia' >>> len(something) 9

where the word "Wikipedia" clearly has 9 letters. Consider also the example of "I am John"

>>> len('I am John') 9

because "I am John" clearly has 9 characters (keep in mind that spaces are counted as well).

The Wikibook Python Programming has a page on the topic of: Lists in Python

The function len can also be used to find the size (i.e. number of elements) of lists, tuples, dictionaries, sets, and other sequence types (any object that implements a __len__ method can be used). Here the list p includes 3 entries:

>>> p = >>> len(p) 3

Read more about this topic:  Len (programming)