I’m trying to get the indeces of the items of my list but on one item it returns a wrong index. There are two numbers who are the same in the list, maybe it confuses it with the first one.
The list is: [0,1,0,0,0,0,0,0,0,0,6,1,0]
for i in neu: if (i > 0): zahl = neu.index(i) + 7 print(zahl) browser.find_element_by_xpath("//*[@id='tabelle_merkliste']/tbody/tr['zahl']/td[10]/img") print("found")
“print(Zahl)” returns these sums: 8 17 8 (should be 18) Maybe someone got an idea why this happens, thanks in advance.
Advertisement
Answer
Use enumerate:
for i, value in enumerate(neu): if (value > 0): zahl = i + 7 print(zahl) browser.find_element_by_xpath("//*[@id='tabelle_merkliste']/tbody/tr['zahl']/td[10]/img") print("found")