Parallel Iteration With Python's zip() Function (Summary)
In this course, you’ve learned how to use Python’s
zip() can receive multiple iterables as input. It returns an iterator that can generate tuples with paired elements from each argument. The resulting iterator can be quite useful when you need to process multiple iterables in a single loop and perform some actions on their items at the same time.
Now you can:
- Use the
zip()function in both Python 3 and Python 2
- Loop over multiple iterables and perform different actions on their items in parallel
- Create and update dictionaries on the fly by zipping two input iterables together
You’ve also coded a few examples that you can use as a starting point for implementing your own solutions using Python’s
zip() function. Feel free to modify these examples as you explore
zip() in depth!
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
Over the course of this tutorial series, you’ve become a power user of the Python
zip() function. You’ve learned in great detail how’s
zip() works, how
zip() has changed from Python 2 to Python 3, as well as how to modify your code as needed to deal with those changes.
You’ve learned how to use the
zip() function for parallel iteration, to create dictionaries and sort iterators on the fly, and then how to combine
zip() with list and dictionary comprehensions to generate really concise, readable output in list and dictionary form.
Become a Member to join the conversation.