-2
**Write a function called 'positions' that you take as input arguments a tuple and an item, and returns a list containing all the indexes in which the item appears on tuple. If the item does not exist in the tuple, it should return an empty list. ** -MY CODE
tupla = (5, 6, 5, 3, 5)
def posicoes(tupla, item):
indice = 0
for i in range(len(tupla)):
if item in tupla(i):
indice.append((i))
return indice
print(posicoes(tupla,5))
You are trying to use the method
.append()
in a variable that receives 0, where it defines the variableindice
, should beindice = []
.– Felipe Gambini
po, you’re right, I forgot to change when posting
– Vinicius Mota