How to append an array in Python
Overview
An array in Python is used to store multiple values of the same type in a single variable.
The word “append” means “to attach to,” which gives us a clue as to what this shot is all about. To attach an item or value to an existing array, we use the append() function, which appends a new item with a value to the end of the array.
append(x)
Where x is the value that we are attaching to the existing variable.
Parameter value
The append() function takes the value to which we want to add or attach an argument.
Return value
The append() function returns an array containing the new value added to the end of the array.
Example
# importing the array moduleimport array as arr# creating an integer data type arrayx = arr.array('i', [1,2,3,4,5,6,7])# using the append functionx.append(100)# printing the new arrayprint(x)