extra a column from a 2-D array?

Uwe Lauth Uwe.Lauth at cursor.de
Tue May 10 06:57:38 EDT 2005


Joe Wong wrote:
(original posting not on my nntp server)
>>Hello,
>> 
>> Suppose I have a python array as follow:
>> 
>>    s=[ [1,3,5],
>>        [2,4,6],
>>        [9,8,7]]
>> 
>>what is the quickest way to extract the second colum from all rows? That 
>>is: [3,4,8] in this example.

[a[1] for a in s]

Uwe



More information about the Python-list mailing list