You are trying to modify a list by using "for i in range of original list" while removing items from it, the list obviously becomes smaller than the range and just stops by the third iteration
Do this instead.
a = [1,3,4,5]
while a:
print(a.pop())
print(a)