# define a list
my_list = ['a', 'b', 'c', 'd']
# Get length of the list using len() method
result = len(my_list)
# Print the result
print(result)
The len() function takes the list as a parameter and returns its length in integer format. In the above example, we are passing a list my_list inside the len() function. The list has four items in it so the function len(my_list) will return 4.
Syntax
len(List)
0 Comments