OneBite.Dev - Coding blog in a bite size

merge multiple array in python

Code snippet on how to merge multiple array in python

# Create arrays
arr1 = [1, 2, 3, 4]
arr2 = [5, 6, 7, 8]

# Using extend() method to merge both arrays
arr1.extend(arr2) 

# Printing Merged Array
print("Merged Array :", arr1) 

This code creates two arrays, arr1 and arr2, which contain four elements each. Then, the extend() method is used to merge both of the arrays and the result is stored in arr1. Lastly, we are printing arr1, which now contains all the elements of arr1 and arr2.

python