Published
- 1 min read
check odd numbers numpy
The solution for this is noted below
check odd numbers numpy
Solution
# Input
arr = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
arr[arr % 2 == 1]
#> array([1, 3, 5, 7, 9])
Try other methods by searching on the site. That is if this doesn’t work