When a for loop starts, it creates an iterator over the list. The
iterator keeps track of the index of the elements, and the loop
continues to retrieve elements based on this index, irrespective of
any changes made to the list during iteration.
In contrast, a while loop does not rely on an iterator. Instead, it
re-evaluates the condition at the beginning of each iteration.
a = [1, 3, 4, 5]
while a:
print(a.pop())
print('Stack empty')