DEV Community

Mr #1738
Mr #1738

Posted on

Getting a List’s Length with len()

The len() function will return the number of values that are in a list value passed to it, just like it can count the number of characters in a string value.
Enter the following into the interactive shell to see the output:

>>> spam = ['cat', 'dog', 'moose']
>>> len(spam)
3
Enter fullscreen mode Exit fullscreen mode

Top comments (0)