About python while statement and pop()
Mark H Harris
harrismh777 at gmail.com
Thu Jun 12 13:07:02 EDT 2014
On 6/12/14 11:55 AM, Marko Rauhamaa wrote:
> while not done:
>
> Better Python and not bad English, either.
... and taking Marko's good advice, what I think you really wanted:
>>> def poplist(L):
done = False
while not done:
yield L[::-1][:1:]
L = L[::-1][1::][::-1]
if len(L)==0: done=True
>>> 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]
>>>
More information about the Python-list
mailing list