I have to lists of numbers, I want to save the difference between each parallel cells I need something like this:
diffEx = [(myEx - opEx) for myEx,opEx in (myExeptPack,opExeptPack)]
eg.
listA = [1,2,3]
listB = [4,3,2]
diff = [-3,-1,1]
Thank you
Use zip function:
diffEx = [(myEx - opEx) for myEx,opEx in zip(myExeptPack,opExeptPack)]
You could use map to make the statement more concise than when using zip:
import operator
diffEx = map(operator.sub, myExeptPack, opExeptPack)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With