len()
function is used to find the the number of items (length) of an object in Python for the given input.
len()
function is a part of Python Built-in Functions.
Syntax of len()
Function
The syntax of
len()
function in Python is:
len(s)
Parameters of len()
Function in Python
x
– Where x
is any valid . This parameter is required.
Compatibility
len()
function is available and compatible with both Python 2.x
and 3.x
.
Return Value of len()
Function in Python
len()
function returns the number of items (length) of an object for the given input.
Python len()
Function Example 1
Example CODE
Output:
Python len()
Function Example 2
Example CODE
Output: