Syntax:

Parameters:

Value: the given value you want the length of.

Return value

It will return an integer value i.e. the length of the given string, or array, or list or collections. Various types of Return values:

Strings:

It returns the number of characters in a string, which includes punctuation, space, and all type of special characters. However, you should be very careful while using len of a Null variable.

Empty:

Empty is a second return call which has zero characters, but it is always None.

Collections:

The len built-in returns the number of elements in a collection.

TypeError:

Len function depends on the type of the variable passed to it. A Non-Type does not have any built-in support.

Dictionary:

For the dictionary, each pair is counted as one unit. However, values and keys are not independent.

Example 1: How find the length of the given string?

Output:

Example 2: How to find the length of the list in python?

Output:

Example 3: How to find the length of a tuple in python

Output:

Example 4: How to find the length of the dictionary in Python?

Output:

Example 5: How to find the length of the array in python

Output:

Summary:

len() is a built-in function in python.You can use the len() to get the length of the given string, array, list, tuple, dictionary, etc. Value: the given value you want the length of. Return value a return an integer value i.e. the length of the given string, or array, or list, or collections.