This question already has an answer here:
I wrote a simple code, but I cannot manage to solve the error. I have checked the other question like this but cannot find the proper answer. the error is:
[ 0.31168528]
Traceback (most recent call last):
File "...................... line 11, in <module>
if l>h:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I expect the answer to be like this. For example, if l
is bigger than h
we have output like:
[ 0.47140332]
[ 0.06389642 0.60366298]
[ 0.15031868 0.79806637 0.41722212]
[ 0.07109745 0.07426005 0.66489767 0.90810382]
>>>
The code is:
from numpy import *
import numpy as np
a=1
b=0.5
for i in range (1,5):
r=np.random.uniform(0,3,i)
x=np.random.uniform(0,3,i)
h=np.random.uniform(0,1,i)
l=r+x
if l>h:
q=h
elif l<3:
q=x
print(q)
Aucun commentaire:
Enregistrer un commentaire