python-jose

Is there a Python function for checking the length of an array?


I need to count the number of items in an array. Is there a function to do it? I can do it with a for loop but if there was a function it would be 100 times easier.

arr1 = [10, 12, 87, 36, 11, 9, 73]
for each in arr1:
    x += 1
 print x

Solution

  • You can try using the length function:

    len(arr1)