Arrays and lists, in Python, have the same way of storing data. But, arrays can hold only a single data type elements whereas lists can hold any data type elements.
Example:
- import array as arr
- User_Array = arr.array(‘i’, [1,2,3,4])
- User_list = [1, ‘abc’, 1.20]
- print (User_Array)
- print (User_list)
Output:
array('i', [1, 2, 3, 4]) [1, 'abc', 1.2]