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]
JavaScript
x
11
11
1
for i in neu:
2
3
if (i > 0):
4
5
zahl = neu.index(i) + 7
6
print(zahl)
7
8
browser.find_element_by_xpath("//*[@id='tabelle_merkliste']/tbody/tr['zahl']/td[10]/img")
9
10
print("found")
11
“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:
JavaScript
1
10
10
1
for i, value in enumerate(neu):
2
if (value > 0):
3
4
zahl = i + 7
5
print(zahl)
6
7
browser.find_element_by_xpath("//*[@id='tabelle_merkliste']/tbody/tr['zahl']/td[10]/img")
8
9
print("found")
10