My issue
ans is coming wrong
My code
# First array
arr1 = [1, 2, 3]
# Second array
arr2 = [4, 5, 6]
# Step 1: Create a new array by merging both arrays directly
merged_array = arr1 + arr2 # Concatenate arr1 and arr2 to form merged_array
# Print the merged array
print("Merged array:", merged_array)
# Printing the merged array with a for loop
print("Elements of merged array: ", end="")
for i in range(len(merged_array)):
print(merged_array[i], end=" ") # Prints the elements on the same line
print() # Move to the next line after printing all elements
Merged array: [1, 2, 3, 4, 5, 6]
Elements of merged array: 1 2 3 4 5 6
Learning course: Data structures & Algorithms lab
Problem Link: Merging 2 arrays in Data structures & Algorithms lab