Note that this site is in currently in version 1.0.0-alpha.   Some functionality may be limited.

len()

len() is a function that calculates the length of the object within the parenthesis. For a string, it will count the number of characters: len("hello") will return 5, and len("hi there") will return 8, because it counts blank spaces. For a list, len() will count the number of list items:

>>> groceries = ["berries", "bananas", "oat milk", "eggs", "spinach", "bell peppers", "ice cream", "frozen pizza", "floss", "hand soap"]
>>> len(groceries)
10

Readings

len()
Read more about len() and more things it can calculate.

Tutorials

Tutorial
Check out len() on w3schools.

Lessons referring to this term