Use in Python
In Python, len
can be used to denote the length of a string:
where the word "Wikipedia" clearly has 9 letters. Consider also the example of "I am John"
>>> len('I am John') 9because "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:
Read more about this topic: Len (programming)