is there a better way?
Schüle Daniel
uval at rz.uni-karlsruhe.de
Fri Feb 10 17:38:23 EST 2006
[...]
> I have been using something like this:
> _____________________
>
> while list[0] != O:
> storage.append(list[0])
> list.pop(0)
> if len(list) == 0:
> break
> _____________________
>
> But this seems ugly to me, and using "while" give me the heebies. Is
> there a better approach?
>>> lst = [1,2,3,4,5,0,0,0,0]
>>> del lst[lst.index(0):]
>>> lst
[1, 2, 3, 4, 5]
>>>
Regards, Daniel
More information about the Python-list
mailing list