Logo

Programming-Idioms

History of Idiom 163 > diff from v5 to v6

Edit summary for version 6 by programming-idioms.org:
[Python] list Works fine without trailing underscore

Version 5

2017-10-28, 14:00:36

Version 6

2017-11-18, 23:17:29

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