'why does this happen in the list?

I am gonna print numbers less than 5, but the answer is not what I mean? how should I solve the problem?

a= [1,2,3,4,5,6,7,8,9]
for b in a:
 if b>=5:
  a.remove(b)      
print(a)

answer:

[1, 2, 3, 4, 6, 8]


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source