Pybites Logo

Sum indices

Level: Intermediate (score: 3)

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