What is the difference between an array and a list?

Hi I need to know the difference between an array and a list

Hi @richards12. Here to see you raising the fundamental question again, though I think doing some Google search might help you with the question.

In my understanding, compared to list, array.array:

  • Restrict its elements to follow a uniform type
  • More space-saving.

Though I haven’t seen array widely used in the wild. Data scientists use numpy.array much more often.

An array is, generally, a sequence with a definite size whose elements
you can access by an index.

Python’s “list” type is its implementation of an array.

Python also has an “array” module, which has to do with compact storage
of basic C-like types: characters, ints of various sizes, floats.

And numpy (a popular numerical computing library for Python) also has
arrays of various types.

Cameron Simpson cs@cskk.id.au