[Solved] Remove sequential repeats from python list [closed]


Using a simple loop (and assuming l the input list):

prev = -float('inf')
out = []
for x in l:
    if x[0]>prev+1:
        out.append(x)
    prev=x[0]

output: [[0, 100], [5, 600], [9, 300], [11, 100], [14, 300]]

0

solved Remove sequential repeats from python list [closed]