i write a code to separate int from the list
when i write the code that way not working
list_a = [1,2,3,4,5,6,7,8,'Ahmed','Mustafa',100,103,107]
list_b = []
x = 0
for item in list_a:
if isinstance(item, int):
list_b.append(item)
list_a.pop(x)
x +=1
print (list_a)
print (list_b)
print (x)
and that`s my output
[2, 4, 6, 8, 'Ahmed', 'Mustafa', 103]
[1, 3, 5, 7, 100, 107]
8
and the code work in this way
list_a = [1,2,3,4,5,6,7,8,'Ahmed','Mustafa',100,103,107]
list_b = []
list_d = []
x = 0
for item in list_a:
if isinstance(item, int):
list_b.append(item)
else :
list_d.append(item)
x +=1
print (list_a)
print (list_b)
print (list_d)
print (x)
why that glitch happened ?