Menu Close

Python len () Function

Here we are going to learn all about the Python len() function to get the length of the python object.len function in python is mostly used by python programmers.

In previous tutorials, we have seen the python iter() function to returns the iterator object.

Table of Contents

Python len function

Python len function is a built-in function in python that is used to find the length of the python object.

Syntax

The syntax of len function in python is:-

len(object)

Parameter

len function in python accepts one parameter that will be python object.

Return Value

Return value of len function in python is length of the python object.

Python len example

Here we will take an example to understand the python len() function.

Example

#length of the string
print(len('Programming Funda'))

#length of the list
print(len([1, 2, 3, 4, 5, 6, 7, 8]))

#length of the set
print(len({'Python', 'Java', 'C++', 'C', 'PHP'}))

#length of the tuple
print(len((1, 2, 3, 4)))

Output

17
8
5
4

Conclusion

In this article, you have learned all about the python len() function to get the length of the python object.
This function will helpful for you in the future. If you like this article, please share and keep visiting for further python built-in functions tutorials.

Python built-in functions

For more information:- Click Here

Previous Article
Next Article

Was this post helpful?

Related Posts

Leave a Reply