avatar Bite 287. Sum indices

Write a function that accepts a list of strings and returns the total of the indices of the items.   

Example 1: ['a', 'b', 'c'] => 0 + 1 + 2 = 3

The indices for duplicate items should be accumulated in the total as they appear.  

Example 2:  ['a', 'b', 'b', 'c'] => 0 + 1 + (1+2) + 3 = 7

Example 3: ['a', 'b', 'b', 'c', 'a', 'b', 'a'] => 0 + 1 + (1+2) + 3 + (0+4) + (1+2+5) + (0+4+6) = 29

 

Login and get coding
go back Intermediate level
Bitecoin 3X

48 out of 48 users completed this Bite.
Will you be Pythonista #49 to crack this Bite?
Resolution time: ~36 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 3.0 on a 1-10 difficulty scale.
» You can do it! 😌

We use Python 3.8