On 6/11/14 10:12 PM, hito koto wrote:
def foo(x): y = [] while x !=[]: y.append(x.pop()) return y
Consider this generator variation:
>>> def poplist(L):
done = False
while done==False:
yield L[::-1][:1:]
L = L[::-1][1::][::-1]
if len(L)==0: done=True
>>> L1=[1, 2, 3, 4, 5, 6, 7]
>>> for n in poplist(L1):
print(n)
[7]
[6]
[5]
[4]
[3]
[2]
[1]
>>>
--
https://mail.python.org/mailman/listinfo/python-list
