Iterating through a two lists in parallel is natively handled in Python using the zip
function.
Iterate through two lists using zip
Python’s zip
function will aggregate elements from two or more iterables.
|
|
Output:
|
|
This works with any number of iterables:
|
|
Output:
|
|
If the index is necessary, use enumerate
:
|
|
Output:
|
|