I have a list like below:
mylist = [((-1), (2)) ,((-3-4j), (5-6j)), ((-3+4j), (5+6j)), ((-7-8j), (-9-10j)), ((-7+8j), (-9+10j)), ((-11-12j), (13+14j)), ((-11+12j), (13+14j))]
I want to check two conditions on this list. For example, for the second element, ((-3-4j), (5-6j)), I want to check if the real part of 5-6j is positive and the sign of imaginary parts of (-3-4j) and (5-6j) is different then I want to know the number of that element in my list. The first element consists of two real numbers, and since 2 is positive, the first element meets the condition. As you can see, only the first element and the last two elements meet the conditions.
I have written a code based on things that I found but it only checks the real part of the second number of each element.
violates = [i for i, a in enumerate(mylist) if any([aa.real > 0 for aa in a])]
print ("violates=", violates)
The output, based on the conditions must be 0, 5 and 6. Thanks for any help.
Aucun commentaire:
Enregistrer un commentaire