Python:delete number in list -
this question has answer here:
- loop “forgets” remove items [duplicate] 10 answers
i learn python.i have problem here.it simple code,but don't know why result unexpected.
here code:
a=[1,2,3,4,6,7,'dd','ss','gg','oo',8] in a: b in range(10): if i==b: a.remove(i) print
i want delete number in a. expecting result a=['dd','ss','gg','00'] result :
[2, 4, 7, 'dd', 'ss', 'gg', 'oo']
i cannot understand why result this.
can me? thank you!
try remove integer list
= [x x in if not isinstance(x, int)]
Comments
Post a Comment