Apr 24, 2025
len() Function Overviewlen() function returns the number of items in an object.len(object)
mylist = ["apple", "banana", "cherry"]
x = len(mylist) # Returns 3
mystring = "Hello"
x = len(mystring) # Returns 5
len() function with different Python sequences and collections to understand its general use.This guide provides an overview of how to use the len() function in Python, offering examples and syntax details to support learning and application.