Counting Elements

Given a list my_list, how can you know how many elements does it have? The answer is simple: the len function:

my_list = ['a', 'b', 'c']

print(len(my_list))  # 3


new_length = len(my_list)
print(new_length)  # 4

We usually refer to "counting elements" as "getting the length of a list". You can associate the len function with the length word.

Jump to the next lesson to start practicing how to create lists and compute the lenght of them...