How To Get The Length Of An Array In Python
Chapter:
Python
Last Updated:
27-05-2023 12:44:44 UTC
Program:
/* ............... START ............... */
my_array = [1, 2, 3, 4, 5]
length = len(my_array)
print(length)
/* ............... END ............... */
Output
Notes:
-
In the example above, len(my_array) returns the length of the my_array list, which is 5. The len() function can be used with other iterable objects like strings, tuples, sets, and dictionaries as well.