Easy Tutorial
❮ Python Merge Sort Python Data Type ❯

Python3 len() Method

Python3 Strings


Description

The Python len() method returns the length of an object (string, list, tuple, etc.) or the number of items.

Syntax

Syntax for the len() method:

len( s )

Parameters

Return Value

Returns the length of the object.

Examples

The following examples demonstrate the use of len():

>>> str = "tutorialpro"
>>> len(str)             # Length of the string
6
>>> l = [1,2,3,4,5]
>>> len(l)               # Number of elements in the list
5

Python3 Strings

❮ Python Merge Sort Python Data Type ❯