+ 2
Can anyone explain the basic difference between list and array?
5 Answers
+ 5
An array is a storage with a fixed size. Once created, you cannot change the size. But you can delete and add elements to a list on runtime.
To get a similar effect for the array with size 'n' you have to create an array with size 'n+1', copy the n elements inside this and add your new element to the n+1th place. :)
+ 5
In addition to Tom Hammerbacher I want to say that an array usually only stores elements of the same type whereas lists don't necessarily have that constraint.
In Python there is actually no data structure called array in the standard lib. Peeps use the module numpy for that because mathematical operations on numpy arrays are much faster (and more convenient) than on lists.
+ 3
Seb TheS Darn, u r actually right. Don't know how they have kept it secret from me for the last 3 years. Probably because noone is using it. Its use seems to be limited to the few cases where u need a 1d array but don't want to do any math on it.
+ 2
Thoq!
Isn't there a module called "array" in the standard library?
+ 1
array is a similar data type and list a disimilar data type array is a static and list is a daynamic