I want to convert a list like this
l1 = [1,2,3,4,5,6,7,8]
to
l2 = [(1,2),(3,4),(5,6),(7,8)]
because want to loop
for x,y in l2:
draw_thing(x,y)
One good way is:
from itertools import izip
it = iter([1, 2, 3, 4])
for x, y in izip(it, it):
print x, y
Output:
1 2
3 4
>>>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With