Logo

Programming-Idioms

History of Idiom 143 > diff from v14 to v15

Edit summary for version 15 by Xris:
[Python] Add comments to explain what will happen if the lengths are not the same.

Version 14

2018-03-27, 11:50:35

Version 15

2018-03-27, 11:56:30

Idiom #143 Iterate alternatively over two lists

Iterate alternatively over the elements of the list items1 and items2. For each iteration, print the element.

Explain what happens if items1 and items2 have different size.

Idiom #143 Iterate alternatively over two lists

Iterate alternatively over the elements of the list items1 and items2. For each iteration, print the element.

Explain what happens if items1 and items2 have different size.

Extra Keywords
parallel
Extra Keywords
parallel
Code
for pair in zip(item1, item2): print(pair)
Code
for pair in zip(item1, item2): print(pair)
Comments bubble
This will print former min(len(item1), item(2)) pairs if len(item1) != len(item2).