Super learner
This user is a Super Learner. To become a Super Learner, you need to reach Level 8.
Made a code that the output is confusing
matrix_B = np.array([[1,2,3,4,5], [2,7,5,2,9], [12,13,7,6,8]])
matrix_B
Here is the code ---> matrix_B[matrix_B[:,:] % 2 == 0] | matrix_B[matrix_B[:,:] >5] #i don't understand this code...
below is the output
array([ 7, 13, 14, 15, 15, 6, 8], dtype=int32)
3 answers ( 0 marked as helpful)
Hi Arowesegbe,
thanks for reaching out! In order to create a condition where the output is an array containing even numbers or numbers greater than 5, you need the following syntax:
matrix_B[(matrix_B[:,:] % 2 == 0) | (matrix_B[:,:] >5)]
Hope this helps!
Best,
365 Eli
Super learner
This user is a Super Learner. To become a Super Learner, you need to reach Level 8.
Thank you very much. it works
Don't forget the parentheses!