Python String len() Method
The Python len() method returns the length of an object (character, list, tuple, etc.) or the number of items.
Python String len() Syntax
The len() method syntax:
len(s)
Python String len() Parameters
- s – Object.
Python String len() Return Value
Returns the length of the object.
Python String len() Example#1
Calculate the length of tuples and lists.
tup = (6,7,8)
print(len(tup))
# list
l = [1,2,3,4]
print(len(l))
Output:
Python String len() Example#2
len() TypeError。
print(len(True))
Output: