1

I have a simple loop to enter the index and value of unique sequence from list entries into a dictionary:

dicter = dict()
prevval = None
for x in range(0, 102):##first lap - ##CHANGE THIS 
    if speedlist[x] != prevval:
        dicter[x] = speedlist[x]
    prevval = speedlist[x]

but for whatever reason it's skipping entries that work fine if I use lists. The first number of entries in speedlist look like this:

12,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5,5,5,5,5

but the dict ends up with only this in it:

{0: 12, 39: 10, 73: 8, 10: 11, 107: 6, 88: 7, 58: 9, 135: 5}

Notice how there's no 11 entry between between the first 0:12 and 39:10 I am assuming this has something to do with the 11 value that appears later but that shouldn't clobber my first 11 entry since the 11 is the value, not the key. No?

cgbeige
  • 11
  • 3

0 Answers0