i have to write a program that get the number of time that an item (linked to another list)occours into a list , i write an example to understand: i have 2 lists:
l=[13, 14, 14, 8, 13, 13, 14, 14, 8, 13 ] and l1=['pea', 'rpai', 'rpai', 'schiai', 'pea', 'rpe', 'zoi', 'zoi', 'briai ', 'rpe']
now, every item of l is linked at only and only one item of l1 (so 13--'pea', 14--'rpai' ecc) like a bijective function. i want to create a third list l2 that associate 1 number to all the equal "tuple" (es. 13--'pea' =1, 14--'rpai'=2 ) so if during cycle i met again another equal tuple i link directly the number associated (so if i get again like the 4th element of l1 13--'pea' im gonna link again the number 1)... that's what i created, but it doestn seems to work , anyone can let me understand what s goin wrong? thanks
for i in lista:
if i not in pro:
pro.append(i)
l2.append(conta)
d[i[1]]=conta
conta+=1
else:
a=d.get(i[1])
l2.append(a)
now "lista" is the list that contain the tuple of the 2 lists (so be like = [(13, 'pea), (14,'rpai') ecc] pro is an initial empty list and l2 is the final result, d is a dict that i use to create the connection from l element and l1 (d={13:0, 14:1 ...}) , but i cant understand where is the errror, any suggestion=? thanks!