-1
This is my code:
def procuras(lista,valor):
dicionario = {}
for valor in lista:
if valor in dicionario:
dicionario[valor] = [i for i, item in enumerate(lista) if item == valor]
else:
dicionario[valor] = lista.index(valor)
return (dicionario[valor])
Runs this way:
procuras([5,2,5,4,5,2,3,5], 5)
The result is always 8
even if I try to see another value.
I needed to get:
procuras([1,2,1,4,5,2,3,1], 2)
[1, 5]
- or is all the indexes where it appears.
If it doesn’t exist you should just give it to me: []
Thank you worked :D
– PipocaInsuflada