What is the difference between Python Arrays and lists?

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:

  1. import array as arr  
  2. User_Array = arr.array(‘i’, [1,2,3,4])  
  3. User_list = [1, ‘abc’, 1.20]  
  4. print (User_Array)  
  5. print (User_list)  

Output:

array('i', [1, 2, 3, 4])
[1, 'abc', 1.2]