hi hope you are well. I wrote code below but I am getting error maybe you can help me where I am doing wrong.

*{Moderator Edit: Solution Code Removed}*

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

1 Like

Note that `A2`

is an array and you are using conditional expression to assign a single value (either 1 or 0) to it. So, Python does not understand how to compare a whole array to a single value. You may use `np.where`

or a method mentioned in the notebook to do this task.

In the notebook, we have:

*As an example, if you would like to set the entries of a matrix X to 0 and 1 based on a threshold you would do: *`X_new = (X > threshold)`

Best,

Saif.

PS: Sharing your code is not allowed. Next time, only share your full error (not the code). Also note that this is a week 3 assignment, not week 2. Please post the correct information to respect everyone’s time. I am editing your post for now but next time, be careful.