Back
In Python, is the following the only way to get the number of elements?
arr.__len__()
If so, why the strange syntax?
my_list = [1,2,3,4,5]len(my_list)
my_list = [1,2,3,4,5]
len(my_list)
So instead of arr.__len__() you can use:-
import arrayarr = array.array('i')arr.append('2') len(arr)
import array
arr = array.array('i')
arr.append('2')
len(arr)
To know more about this you can have a look at the following video tutorial:-
Learn more about Python from an expert. Enroll in our Python Course
31k questions
32.8k answers
501 comments
693 users