Basically I want to remove elements from a secondary list based on the result of another list. I have two lists:
lista_8 = ['', '', 'Preco', '', 'Preco', '', '', 'Preco']
lista_n = ['positivo', 'positivo', 'negativo', 'positivo', 'negativo', 'positivo', 'positivo', 'negativo']
Follow logic:
When the element of lista_8
is empty, the element of lista_n
is also empty, otherwise it keeps the result (positive or negative).
My code looks like this:
for w in lista_8:
if lista_8[w] == 0:
lista_n[w+1] = 0
print lista(n)
The following error occurs:
if_list_8 [w] == 0:
TypeError: list indices must be integers or slices, not str