Programming-Idioms

History of Idiom 163 > diff from v5 to v6

Edit summary for version 6 :
[Python] list Works fine without trailing underscore

Version 5

Version 6

Idiom #163 Print list elements by group of 2

Print all the list elements, two by two, assuming list length is even.

Idiom #163 Print list elements by group of 2

Print all the list elements, two by two, assuming list length is even.

Code
for x in zip(list_[::2], list_[1::2]):
    print(x)
Code
for x in zip(list[::2], list[1::2]):
    print(x)
Comments bubble
original list is called list_
Comments bubble
original list is called list