What is Python List?
A Python list is a collection that is ordered and changeable. In Python, lists are written with square brackets.
Some important points about Python Lists:
- The list can be homogeneous or heterogeneous.
- Element-wise operation is not possible on the list.
- Python list is by default 1-dimensional. But we can create an N-Dimensional list. But then too it will be 1 D list storing another 1D list
- Elements of a list need not be contiguous in memory.
Below are some examples which clearly demonstrate how Numpy arrays are better than Python lists by analyzing the memory consumption, execution time comparison, and operations supported by both of them.
Representation of Python List
Here we are creating Python List using []
Python3
Var = [ "Geeks" , "for" , "Geeks" ] print (Var) |
Output:
["Geeks", "for", "Geeks"]
Python Lists VS Numpy Arrays
Here, we will understand the difference between Python List and Python Numpy array.