I'm trying to go through a list and delete elements that have numerical values that are one value greater/lower than the value that I'm looking at.
My lists are:
slice=[77.0, 115.0, 116.0, 130.0, 140.0, 141.0, 142.0, 144.0, 145.0, 146.0, 151.0, 152.0, 163.0, 166.0, 169.0, 187.0, 188.0, 197.0, 198.0, 199.0, 210.0, 218.0, 219.0, 250.0, 251.0, 256.0, 257.0, 264.0, 279.0, 280.0, 288.0, 291.0, 298.0, 299.0, 329.0, 330.0, 331.0, 336.0, 337.0, 349.0, 358.0, 372.0, 373.0, 374.0, 376.0, 424.0, 425.0]
count=[14, 10, 7, 5, 4, 5, 5, 14, 5, 11, 6, 2, 12, 2, 3, 6, 8, 5, 7, 8, 3, 28, 16, 2, 5, 3, 25, 2, 2, 2, 2, 2, 32, 2, 2, 34, 2, 5, 11, 5, 2, 6, 6, 28, 13, 4, 13]
Basically, I want to start on the second element of the slice list (i.e. i=1, which is 115) and see if i+1 or i-1 exists (in this case, i+1 exists, 116); if so, I then want compare the count values of said slices, and delete the slice and (corresponding count value) that has the lowest count value. After this, I want to move onto the next value on the list (i.e. i=2) and loop this process until I get to the end of the list.
I'm very new to python (my only coding experience prior to this is having done the codecademy python course over 6 months ago), so I'm sorry if these instructions are a bit vague...
My lists are:
slice=[77.0, 115.0, 116.0, 130.0, 140.0, 141.0, 142.0, 144.0, 145.0, 146.0, 151.0, 152.0, 163.0, 166.0, 169.0, 187.0, 188.0, 197.0, 198.0, 199.0, 210.0, 218.0, 219.0, 250.0, 251.0, 256.0, 257.0, 264.0, 279.0, 280.0, 288.0, 291.0, 298.0, 299.0, 329.0, 330.0, 331.0, 336.0, 337.0, 349.0, 358.0, 372.0, 373.0, 374.0, 376.0, 424.0, 425.0]
count=[14, 10, 7, 5, 4, 5, 5, 14, 5, 11, 6, 2, 12, 2, 3, 6, 8, 5, 7, 8, 3, 28, 16, 2, 5, 3, 25, 2, 2, 2, 2, 2, 32, 2, 2, 34, 2, 5, 11, 5, 2, 6, 6, 28, 13, 4, 13]
Basically, I want to start on the second element of the slice list (i.e. i=1, which is 115) and see if i+1 or i-1 exists (in this case, i+1 exists, 116); if so, I then want compare the count values of said slices, and delete the slice and (corresponding count value) that has the lowest count value. After this, I want to move onto the next value on the list (i.e. i=2) and loop this process until I get to the end of the list.
I'm very new to python (my only coding experience prior to this is having done the codecademy python course over 6 months ago), so I'm sorry if these instructions are a bit vague...