DEV Community

Tommi k Vincent
Tommi k Vincent

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)