So, i have 2 loops, one inside of another, both having lists to iterate and work with, but both break when the first finishes iteration (so, outer one breaks prematurely). I really want to hear why this happens. And also, what to do to perform stuff in the inner loop for the whole list that outer loop uses? Output is at the end
kk = list(range(1, 10)) # [1,2,3,4,5,6,7,8,9]
for l in kk: # for example, l = 2
for d in [2, 3]: # d = 2
g = l * d # l = 2, g = 4
if g >= 9:
break
else:
kk.remove(g) # should remove 4 from kk, but did not
print(kk)
continue
continue
C:\Users\Denis\Python\Python36-32\python.exe C:/Users/Denis/PycharmProjects/interesting_stuff/other
[1, 3, 4, 5, 6, 7, 8, 9]
[1, 4, 5, 6, 7, 8, 9]
[1, 4, 5, 6, 7, 9]
Process finished with exit code 0