<aaron.m.weisb...@gmail.com> a écrit dans le message de news:621ca9d5-79b1-44c9-b534-3ad1b0cf4...@googlegroups.com...
Hi,

I'm having difficulty thinking about how to do this as a Python beginner.

But I have a list that is represented as:

[1,2,3,4,5,6,7,8]

and I would like the following results:

[1,2] [3,4] [5,6] [7,8]

Any ideas?

Thanks

list(zip(L[0::2], L[1::2]))
[(1, 2), (3, 4), (5, 6), (7, 8)]

list(map(list, zip(L[0::2], L[1::2])))
[[1, 2], [3, 4], [5, 6], [7, 8]]

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to