mardi 24 avril 2018

Python array elements in if statement

I have some array with integers, and for loop. I am trying to test if some specific elements in array is bigger or smaller that some integer. This code explain it better:

array = [1,2,3,4,5]
for i in range(5):
if array[i] >= 3:
print(sometext)
else:
print(othertext)

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

Aucun commentaire:

Enregistrer un commentaire