merge two arrays together in python
Code snippet on how to merge two arrays together in python
list1 = [1, 2, 3]
list2 = [4, 5, 6]
# Using +
merged_list = list1 + list2
# Print list
print(merged_list)
The code above merges two arrays together in Python. The first two lines create two lists named ‘list1’ and ‘list2’. The third line uses the ‘+’ operator to combine the two lists. The merged list is named ‘merged_list’. The last line prints out the merged list. The output will be a single combined list, containing all elements of both original lists (e.g. [1,2,3,4,5,6]).