An array is used to store multiple items, elements, or values of the same datatype in a single variable.
The fromlist() function is simply used to append or add a list to the ending of a given array.
array.fromlist(list)
The fromlist() method takes a list as the parameter value.
The fromlist() method returns an array having a list added to the end to the array.
# importing the array moduleimport array as arr# creating an integer data type arrayx = arr.array('i', [1,2,3,4,5,6,7])# creatomg a listy = [8, 9, 10]# using the fromlist() functionx.fromlist(y)# Printing the new arrayprint(x)
x.y.fromlist() function to add the list in y to the array x.x which now has the list values in y added to its ending.