[Tutor] how to convert array into tuple

Ricardo Aráoz ricaraoz at gmail.com
Wed Sep 26 20:39:09 CEST 2007


Fangwen Lu wrote:
> Dear all-
>  
> If I have an array array([1, 2, 3, 4, 5, 6]), and I want to get
> ((1,2),(3,4),(5,6)). What should I do?
>  

tuple([j for (i,j) in enumerate(zip(x, x[1:])) if i % 2 == 0])



More information about the Tutor mailing list