less than 1 minute read

It is used to determine the length of a string, list, array and etc, this mean that returns the number of items in an object.

Example-1:

When the object is a string, the len() function returns the number of characters in the string.

Name = "Ellie"
print(len(Name))

# Output:
5

Example-2:

When the object is a string, the len() function Return the number of items in a list.

Fruits = ["Strawberry", "Blueberry", "Cherry"]
print(len(Fruits))

# Output:
3

Reference

Python len() function