On 6/12/14 11:57 AM, Chris Angelico wrote:
def poplist(L):
done = False
while done==False:
yield L[::-1][:1:]
L = L[::-1][1::][::-1]
if len(L)==0: done=True
Why not just "while L"?
OK, here it is with Chris' excellent advice:
>>> def poplist(L):
while L:
yield L[::-1][:1:]
L = L[::-1][1::][::-1]
>>> L=[1, 2, 3, 4, 5, 6, 7]
>>> m=[]
>>> pop = poplist(L)
>>> for n in poplist(L):
m.append(n[0])
>>> m
[7, 6, 5, 4, 3, 2, 1]
>>>
========== aaaaah ===================
--
https://mail.python.org/mailman/listinfo/python-list