In this python numpy program, we will print all the values from the array except 20 using NumPy.
Steps to solve the program
- Import the numpy library as np.
- Create an array of 1-20 numbers using np.range().
- Use for loop to iterate over the numbers in the array.
- If the number is not equal to 20 then print that number.
import numpy as np
x = np.arange(1,20)
for val in x:
if val != 20:
print(val,end=" ")
Output :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19