List slicing
Alex Martelli
aleax at aleax.it
Mon Oct 7 12:26:42 EDT 2002
Uwe C. Schroeder wrote:
>
> Hi guys,
>
> is there a slicing operation on nested lists ?
Slicing is applicable to any list, nested or otherwise, but it
does not do what you would like it to do here:-).
> i.e.
> list=[[1,2,3],[1,2,3],[1,2,3]]
Avoid naming a variable the same as the type, as that will
hide the type and make it unavailable. Call it 'alist'...:-)
> the result of the operation should give [1,1,1] (or [2,2,2] :-))
[ sublist[0] for sublist in alist ]
etc.
Alex
More information about the Python-list
mailing list