4
In case I have a list x
that contains several values, and some repeated, and I want to have the index for each element, as I can do? I tried to do using the method .index()
but it only returns the index of the first element.
>>> x = ['c','a','s','a']
>>> a.index('a')
1
But what I’m trying to do is to have the index of each letter, even though I have two numbers for the repeated letters and move on to a dictionary:
x_index = {"c":0,"a":(1,3),"s":2}
In the dictionary
x_index
, contents must be stored in tuples/integers or can be stored in arrays?– Gomiero