Full Stack LAMP - MEAN Developer, Python developer. Certified Azure Developer. Freelance programmer/consultant/trainer.

In this tutorial, you will learn about the Python len() function with the help of examples.

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

The syntax of the len() function looks like this:


Where argument may be a sequence (such as a string, bytes, tuple, list, or range) or a collection (such as a dictionary, set, or frozen set).


# compute the length of string.
my_string = "arjunphp"
# Output: 8

languages = ['Python', 'PHP', 'JavaScript']

# compute the length of languages list
length = len(languages)

# Output: 3

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.