2

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?

0

3 Answers 3

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

Sign up to request clarification or add additional context in comments.

2 Comments

Also the Python standard library has arrays, so it's not quite so clear cut: docs.python.org/3/library/array.html
True. I'd say, for learning purposes, a list is the preferred data structure
1

you can check:

type([]) == type(list())

Which returns True.

Just make sure with a friend that [] is a list...

Comments

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.