OneBite.Dev - Coding blog in a bite size

merge two arrays in python

Code snippet on how to merge two arrays in python

  array1 = ["Hello", "my", "name"]
  array2 = ["is", "John"]
 
  merged_array = array1 + array2

  print(merged_array)

The code above shows how to merge two arrays in python. The first two lines declare two arrays, array1 and array2, which contain strings. The third line to the right of the equals sign merges the two arrays together with the plus sign, creating a third array called merged_array. The last line prints the merged_array so that you can see the result. The output would be “Hello, my, name, is, John”.

python