If I have a x
list that contains multiple values, and a few repeats, and I want to have the index for each element, how can I do it? I tried doing it using the .index()
method but it only returns the index of the first element.
>>> x = ['c','a','s','a']
>>> a.index('a')
1
But what I am trying to do is to have the index of each letter, even having two numbers for the repeated letters and move to a dictionary:
x_index = {"c":0,"a":(1,3),"s":2}