0

I wrote the function which supposed to remove minus values from the list. Function removes all minus values except -3 and i have no idea why

def trzecia():
    lista = [2, -1, 3, -2, -3]
    for x in lista:
        if x < 0:
            lista.remove(x)
    print(lista)

trzecia()

Could someone explain me why -3 is still on list?

deceze
  • 510,633
  • 85
  • 743
  • 889
XENON1905
  • 13
  • 1

0 Answers0