Learn Before
Built-In Functions in Python
len()
len() function returns the length or number of items in an object. The object must be a sequence e.g string, list, tuples or a collection e.g dictionary, set.
print(len("apple")) #returns 5 print(len(["a", "b", "c"])) #returns 3 print(len({"age": 20, "score": 100})) #returns 2 print(len(1)) #throws an error: TypeError: object of type 'int' has no len()
0
1
4 years ago
Tags
Python Programming Language
Data Science
Related
print()
input() Function
id()
range()
abs() function
bin()
bool()
len()
round()
pow(x, y, z)
chr(i)
slice()
hex()
oct()
int()
str()
float()
ord()
open()