I have two lists:
A = [476, 1440, 3060, 3060, 500,500]
B = [0,4,10,15]
NOTE: length of list B will always be equal to individual plus number of paired values in list A. Updated list B will match the length of the list A.
I want to check for duplicate values in the list A and use its indexed position to duplicate corresponding value in the list B. For example, list A has A[2]=A[3] and A[4]=A[5] (3060 and 500), so based on this I want to duplicate B[2] and B[3] and add these at B[3] and B[5] respectively. So updated list B would look like:
B = [0,4,10,10,15,15]
I tried following to get start index of duplicate values:
C = [x==A[i-1] for i,x in enumerate(A)][1:]
for idx,l in enumerate(C):
if l == True:
print "idx"
But running short to incorporate this change into list B. Any suggestions would be appreciative.
Bwould be unique, always? and what if the same number occurs more than twice inAA = [200, 500, 3060, 3060, 500]andB = [0,4,10,15]what would be your answer?