List: A list in Python is a collection of items which can contain elements of multiple data types, which may be either numeric, character logical values, etc. It is an ordered collection supporting negative indexing. A list can be created using  containing data values.
Contents of lists can be easily merged and copied using python’s inbuilt functions.
[1, 'Yash', ['a', 'e']]
The first element is an integer, the second a string and the third is an list of characters.
Array: An array is a vector containing homogeneous elements i.e. belonging to the same data type. Elements are allocated with contiguous memory locations allowing easy modification, that is, addition, deletion, accessing of elements. In Python, we have to use the
array module to declare arrays. If the elements of an array belong to different data types, an exception “Incompatible data types” is thrown.
1 2 3
Here are the differences between List and Array in Python :
|Can consist of elements belonging to different data types||Only consists of elements belonging to the same data type|
|No need to explicitly import a module for declaration||Need to explicitly import a module for declaration|
|Cannot directly handle arithmetic operations||Can directly handle arithmetic operations|
|Can be nested to contain different type of elements||Must contain either all nested elements of same size|
|Preferred for shorter sequence of data items||Preferred for longer sequence of data items|
|Greater flexibility allows easy modification (addition, deletion) of data||Less flexibility since addition, deletion has to be done element wise|
|The entire list can be printed without any explicit looping||A loop has to be formed to print or access the components of array|
|Consume larger memory for easy addition of elements||Comparatively more compact in memory size|
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Difference between Singly linked list and Doubly linked list
- Difference between forward list and list in C++
- Python | Convert list of string to list of list
- Python | Convert list of tuples to list of list
- Python | Convert List of String List to String List
- What’s difference between “array” and “&array” for “int array” ?
- Python List Comprehension | Segregate 0's and 1's in an array list
- Python | Maximum absolute difference list of list
- Difference between List comprehension and Lambda in Python
- Python | Difference Between List and Tuple
- Difference between List and Dictionary in Python
- Python program to find sum of absolute difference between all pairs in a list
- Python | Calculate difference between adjacent elements in given list
- Difference between List VS Set VS Tuple in Python
- Difference Between Vector and List
- Difference between List and ArrayList in Java
- Difference between List, Set and Map in Java
- Difference between std::set and std::list
- Difference between pointer to an array and array of pointers
- Difference between Programmable Logic Array and Programming Array Logic
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.