Remove continuous number



Problem to remove continuous number in the given list.



Example-1:


Input    : n = [ 1, 2, 3, 3, 4, 5, 4]
Output   : [1, 2, 4, 5, 4]  


Example-2:


Input    : n = [ 1, 4, 4, 4, 7, 5, 9, 9]
Output   : [1, 7, 5]  







Solution




n = [ 1, 2, 3, 3, 4, 5, 4]

n.append(";")

l = []

for i in range(len(n)-1):

    if(i==0):

        if(n[i] != n[i+1]):

            l.append(n[i])

    else:

        if(n[i] != n[i+1] and n[i] != n[i-1]):

            l.append(n[i])
print(l)



Output



[1, 2, 4, 5, 4]