w3resource logo

:

Python Exercises

Python NumPy: Append values to the end of an array

Python NumPy: Array Object Exercise-12 with Solution

Write a Python program to append values to the end of an array.

Sample Solution:-

Python Code:

import numpy as np
x = [10, 20, 30]
print("Original array:")
print(x)
x = np.append(x, [[40, 50, 60], [70, 80, 90]])
print("After append values to the end of the array:")
print(x)

Sample Output:

Original array:                                                         
[10, 20, 30]                                                            
After append values to the end of the array:                            
[10 20 30 40 50 60 70 80 90]

Python Code Editor:

Improve this sample solution and post your code through Disqus