We can use a while loop on non-empty lists. For example, we can say while a list is not empty, pop a value from the list and perform some operation on the value.
The while loop automatically stops when condition is no longer true or in this case when the list items_in_bag
is empty.