capypad
0 day streak
python / beginner
Snippet

Measuring Length with len()

The len() function is a built-in tool that counts the number of elements in a list, string, or other collection.

snippet.py
python
1
2
3
items = ["apple", "banana", "cherry"]
count = len(items)
print(count)
Breakdown
1
len(items)
Passes the list to the len function to calculate its total number of items.