We use Python 3.6

go back Level: Intermediate (img: IM / score: 3) level Bite 118. List exercise: return first occurrence indices of duplicated words

17 out of 17 users completed this Bite ...
Will you be Pythonista #18 to crack this Bite?
Average Bite difficulty 1-10 rating: 2.0
» You can do it! 😌

In this Bite you are presented with a list of words. Loop through them and find all the words that are duplicated. Of those return the (0-based) indices of the first occurrence.

Example: ['this', 'is', 'a', 'new', 'bite', 'I', 'hope', 'this', 'bite', 'will', 'teach', 'you', 'something', 'new'] would return [0, 3, 4], because this, a, and bite are duplicated and are at index 0, 3 and 4 respectively.

Github login button