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

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:

len(object)

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).

Examples:

# compute the length of string.
my_string = "arjunphp"
print(len(my_string))
# Output: 8

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

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

# Output: 3