Reputation: 327
So I have this list:
toFindIn = ['TRANSPARENT ENCAPSULANT EPOXY HARDENER (5225B-KL) 1215807',
'TRANSPARENT ENCAPSULANT EPOXY RESIN (2282A)',
'TRANSPARENT ENCAPSULANT EPOXY HARDENER (5225B-KL) 1215807',
'MELAMINE COMPOUND CT-6005 (FORMALDEHYDE MOLDING COMPOUND, GL AZING POWDER)',
'(AUTO PARTS FOR CAPTIVE USE) NAMEPLATE COMPASS (PART NO: 533 771200) (QTY: 288 NOS)',
'TRANSPARENT ENCAPSULANT EPOXY HARDENER (5225B-KL) 1215807']
and I would like to print unique index value for each element even though some elements might be repeated. How do I achieve that?
the index list contains:
[0, 1, 0, 3, 4, 0]
instead I would like it to be:
[0, 1, 2, 3, 4, 5]
Upvotes: 0
Views: 52
Reputation: 45261
Two ways:
for index, item in enumerate(toFindIn):
print(index, ", ", item)
Or if you really just want the indexes:
for index in range(len(toFindIn)):
print(index)
If what you want is a list of the indexes:
indexes = list(range(len(toFindIn)))
print(indexes)
Upvotes: 1