a = [2, 3, 4, 5, 10, 12, 13, 17, 1234, 4321, 12345, 13579]
b = a
for i in b:
a.remove(i)
print(a)
The output is [3, 5, 12, 17, 4321, 13579] instead of the expected empty list, why is that so?
Actually I wanted to write a program to remove all integers in a list with at least one even single digit, i.e.
a = [2, 3, 4, 5, 10, 12, 13, 17, 1234, 4321, 12345, 13579]
b = a
for i in b:
if str(j) == 0 or str(j) == 2 or str(j) == 4 or str(j) == 6 or str(j) == 8:
a.remove(i)
print(a)
But that doesn't work in the way expected. How should I debug that?