OneBite.Dev - Coding blog in a bite size

count array's length in python

Code snippet on how to count array's length in python

my_array = ["Alice", "Bob", "Charlie", "Deborah", "Edward"]
array_length = len(my_array)

print(array_length)

This code will count the length of an array in Python. First, a variable, my_array, is set equal to an array of names. Next, a variable array_length is set equal to the length of my_array. Finally, the code will print the length of the array, which in this case is 5.

python