i am trying to remove all digits consisting "five" from a list
it works with with >for loop< but not completely, and i am interested why is there such "anomaly" or i did something wrong?
if i use >filter< function, there is no such problem, all "fives" were removed!
the_list = [i for i in range(101)]
for i in the_list:
if "5" in str(i):
the_list.remove(i)
print(the_list)
Output:
[0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11,
12, 13, 14, 16, 17, 18, 19, 20, 21,
22, 23, 24, 26, 27, 28, 29, 30, 31,
32, 33, 34, 36, 37, 38, 39, 40, 41,
42, 43, 44, 46, 47, 48, 49, 51, 53,
55, 57, 59, 60, 61, 62, 63, 64, 66,
67, 68, 69, 70, 71, 72, 73, 74, 76,
77, 78, 79, 80, 81, 82, 83, 84, 86,
87, 88, 89, 90, 91, 92, 93, 94, 96,
97, 98, 99, 100]
Why [51, 53, 55, 57, 59] are still in the list?