I've used JavaScript before where we use arrays. I'm following a textbook that teaches Python. I'm now learning about lists. They sound exactly like arrays. Is list simply the Python word for array, or does Python have arrays and lists which are different things?
Asked
Active
Viewed 625 times
3 Answers
3
Yes, lists are the data structure in Python.
Sidenote: Numpy (a python library) has arrays
But, as pointed out in the comments Python does, in-fact, have an array
module. Which is a list of all the same data types

OneCricketeer
- 179,855
- 19
- 132
- 245
-
Also the Python standard library has arrays, so it's not quite so clear cut: https://docs.python.org/3/library/array.html – jonrsharpe Apr 23 '16 at 20:46
-
True. I'd say, for learning purposes, a list is the preferred data structure – OneCricketeer Apr 23 '16 at 20:47
1
you can check:
type([]) == type(list())
Which returns True.
Just make sure with a friend that [] is a list...

kpie
- 9,588
- 5
- 28
- 50
1
Python's lists can be treated as arrays, but they are not arrays. They are the closest thing to Javascript arrays, though. Numpy has high performance arrays for numerical computations, but all elements must be of the same type.

Cyb3rFly3r
- 1,321
- 7
- 12