I just learn python.I have a problem here.It is simple code,But I don't know why the result is unexpected.
here is my code:
a=[1,2,3,4,6,7,'dd','ss','gg','oo',8]
for i in a:
for b in range(10):
if i==b:
a.remove(i)
print a
I want to delete the number in a. I am expecting the result will be a=['dd','ss','gg','00'] but the result is :
[2, 4, 7, 'dd', 'ss', 'gg', 'oo']
I cannot understand why the result is this.
Can anyone help me? Thank you!