John Machin wrote: > On May 3, 8:03 am, Tobiah <[EMAIL PROTECTED]> wrote: >> >>> elegant_solution([1,2,3,4,5,6,7,8,9,10]) >> [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] >> > > What is your definition of "elegant"? What about other dimensions of > code quality like "robust" and "fast"? > > What have you tried? > > Here's one possibility: > zip(source[::2], source[1::2]) > [I'm presuming you won't be upset by getting tuples instead of lists]
I like it, and it fits my definition of elegant. -- Posted via a free Usenet account from http://www.teranews.com -- http://mail.python.org/mailman/listinfo/python-list