Apr-18-2017, 03:29 AM
It's pretty simple. The while loop keeps going until there's no elements left. Which is forever, unless you actually remove things from the list. Something like:
>>> items = [4, 34, 6, 7] >>> total = 0 >>> while items: ... total += items.pop() ... >>> total 51 >>> items []