lst = [0,0,1,0,0,2,3,0] ikkeFerdig = True while ikkeFerdig: if lst[0] == 0: lst.pop(0) if lst[len(lst)-1] == 0: lst.pop(len(lst)-1) if lst[0] != 0 and lst[len(lst)-1] != 0: ikkeFerdig = False print(lst)