[Tutor] reverse diagonal

Dave Angel d at davea.name
Sun Dec 2 05:18:44 CET 2012


On 12/01/2012 09:55 PM, eryksun wrote:
> On Sat, Dec 1, 2012 at 9:35 PM, Dave Angel <d at davea.name> wrote:
>>
>> [M[i][~i] for i,dummy in enumerate(M) ]
> 
> Since enumerate() iterates the rows, you could skip the first index:
> 
>     >>> [row[~i] for i,row in enumerate(M)]
>     [3, 5, 7]
> 
> 

Great job.  And I can't see any way to improve on that.

-- 

DaveA


More information about the Tutor mailing list