Both python arrays and list have many simillarities like they both are mutable, i.e. the content of both can be changed
they differ with respect to the followingPython arrays are used when we have to store homogenous type of datawhereas List are used when we need to store hetrogenous kind of data
Example
#Arrayarr=array[(1,2,3),(1,2,3)]#listlist=[1,2,3,4,5,6]
#Array
arr=array[(1,2,3),(1,2,3)]
#list
list=[1,2,3,4,5,6]
one major differnce between the two can be seen by the following example
from array import arrayif __name__=="__main__": arr=array([1,2,3,4,5]) list=[1,2,3,4,5] #this will not result into an error print(arr/5) #this will result into an TypeError: array() argument 1 must be a unicode character, not list print(list/5)
from array import array
if __name__=="__main__":
arr=array([1,2,3,4,5])
list=[1,2,3,4,5]
#this will not result into an error
print(arr/5)
#this will result into an TypeError: array() argument 1 must be a unicode character, not list
print(list/5)
Array : It is collection of variables represented by a common name with a common datatype.The variables are stored contineuosly.So it has element and index which is started from 0.example array(‘d’, [1.0, 2.0, 3.14])Here it is double typefor more …..https://docs.python.org/3/library/array.html
my_list = [1, “Hello”, 3.4]