dimanche 28 octobre 2018

Find when the condition is verified only one time

can you help me for the following problem?

Thank you very much

sss = [[40. 43.]
 [40. 38.]
 [43. 38.]
 [43. 36.]
 [43. 37.]
 [36. 37.]
 [41. 42.]
 [41. 43.]
 [42. 43.]
 [42. 35.]
 [42. 36.]
 [35. 36.]
 [43. 42.]
 [43. 36.]
 [42. 36.]
 [40. 41.]
 [40. 43.]
 [41. 43.]
 [38. 43.]
 [38. 37.]
 [43. 37.]
 [39. 40.]
 [39. 38.]
 [40. 38.]]

matrix_ELEMENTI = [[ 8. 40. 43. 38.]
 [ 7. 43. 36. 37.]
 [ 6. 41. 42. 43.]
 [ 5. 42. 35. 36.]
 [ 4. 43. 42. 36.]
 [ 3. 40. 41. 43.]
 [ 2. 38. 43. 37.]
 [ 1. 39. 40. 38.]]


for q in range(24):
    for w in range(8):
        if (sss[q, :] == matrix_ELEMENTI[w, 1:3]).all() or (sss[q, :] == matrix_ELEMENTI[w, 3:5]).all() or (sss[q, :] == (matrix_ELEMENTI[w, 1], matrix_ELEMENTI[w, 3])).all(): 
            print('>>', matrix_ELEMENTI[w, :])

In this loop I seeking to check if the value of every row of the sss matrix is equal to others pairs value of the matrix_ELEMENTI from the second column to the last column of every row. I need to find when the condition is verified only one time.

Aucun commentaire:

Enregistrer un commentaire