Skip to content

Latest commit

 

History

History
17 lines (11 loc) · 727 Bytes

len.md

File metadata and controls

17 lines (11 loc) · 727 Bytes

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

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

Tutorials

  • Check out len() on w3schools.