dimanche 5 mars 2017

How to use Array elements in a if-else statement?

I have two Numpy arrays, say a and b, each having a single one element only, like: a = ['op 1'] b = ['op 2']

I need to use these two for comparison like

"if outputs are op 1 and op 2 then print op 2"
"else if outputs are op 1 and op 3 then print op 3"
"else if outputs are op 1 and op 1 then print op 1"
"else if outputs are op 2 and op 2 then print op 2"
"else if outputs are op 3 and op 3 then print op 3"

here "outputs" means the content of array 1 and array 2

How can I do this? I'm totally new to Python and NumPy. I saw the NumPy array equal function, but that doesn't work here, right?

Aucun commentaire:

Enregistrer un commentaire