Python 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.
1 2 3 4 5 | import array as arr My_Array=arr.array('i',[1,2,3,4]) My_list=[1,'abc',1.20] print(My_Array) print(My_list) |
Program Output
1 | array(‘i’, [1, 2, 3, 4]) [1, ‘abc’, 1.2] |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.