<[email protected]> a écrit dans le message de news:[email protected]...
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