DEV Community

I'm Just a Guy with a Computer
I'm Just a Guy with a Computer

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)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more