mercredi 24 avril 2019

IF statement for repeating elements

I have interesting question: Let's assume that we have lst = [1,2,3,4,5,5,5,5,5,6,7,8] I am interested on saying to if statement only return result of 3rd 5.
for example:

for i in range(0,lent(lst)):
   if lst[i]==5:
      print(i,"is index of 1st 5")
      break

but how to say ask if to show 3rd 5's index?

Aucun commentaire:

Enregistrer un commentaire