Below is a short piece of code that for some reason keeps generating the following value error message: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all().
import numpy as np
p=np.array([1,2,3])
q=np.array([4,5,5])
while p + q==7:
try:
assert p.any()
assert q.any()
except AssertionError:
print('(p + q)<=6')
print (p + q)
I have tried both p.any
and p.all
, still getting the same error message. Any suggestions? Thanks.