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.

Similar Reads

What is a Numpy array?

NumPy is the fundamental package for scientific computing in Python. Numpy arrays facilitate advanced mathematical and other types of operations on large numbers of data. Typically, such operations are executed more efficiently and with less code than is possible using Python’s built-in sequences. Numpy is not another programming language but a Python extension module. It provides fast and efficient operations on arrays of homogeneous data....

What is Python List?

...

Comparison between Numpy array and Python List

...

Conclusion

A Python list is a collection that is ordered and changeable. In Python, lists are written with square brackets....