I have a program that generates bunch of lists with different variations of (+/-, 1/2)s As an example:
mylist1 = ((+.1),(-,1),(+,2),(-,2))
with various quantities in each list. I am then trying to write an if statement that checks to see if the list the program is currently analyzing contains both (+,1) AND (-,2) or (-,1) AND (+,2). If it does, I will make it add to the counter I have established.
I have attempted to do this using
if '(+, 1)' and '(-, 2)' or '(-, 1)' and '(+, 2)' in all_dict[target][qname]:
and
if any(['+, 1','-, 2']) in all_dict[target][qname][i:i+1]:
But both give lines seem to make the counter go up in lists that don't contain the combination I want.
Aucun commentaire:
Enregistrer un commentaire