lundi 26 mars 2018

Error checking whether an element is in a list

i am trying to check whether certain elements are in a list, and to execute numerical update but i keep getting an error (below).


"if h2output[1] not in h1output == True or h2output[2] not in h1output == True:
IndexError: list index out of range"


doublewin = 0

h1output = []
h2output = []
h3output = []
v1output = []
v2output = []
v3output = []
d1output = []
d2output = []


for i in h1:
    if i not in h1output:
        h1output.append(i)
    if len(h1output) == 2:
        doublewin += 1


for i in h2:
    if i not in h2output:
        h2output.append(i)

if len(h2output) == 2:
    if h2output[1] not in h1output == True or h2output[2] not in h1output == True:
        doublewin += 1

Aucun commentaire:

Enregistrer un commentaire