List slicing

Thorsten Kampe thorsten at thorstenkampe.de
Mon Oct 7 18:53:53 EDT 2002


* Alex Martelli
> Uwe C. Schroeder wrote:
>>  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 ]

zip(*alist)[0]

Thorsten



More information about the Python-list mailing list