Someone asked How to do Python’s zip in C#?...
...which leads me to ask, what good is zip? In what scenarios do I need this? Is it really so foundational that I n
zip is useful if you'd like to iterate over multiple iterables simultaneously, which is a reasonably common scenario in Python.
One real-world scenario where zip has come in handy for me is if you have an M by N array, and you want to look at columns instead of rows. For example:
>>> five_by_two = ((0, 1), (1, 2), (2, 3), (3, 4), (4, 5))
>>> two_by_five = tuple(zip(*five_by_two))
>>> two_by_five
((0, 1, 2, 3, 4), (1, 2, 3, 4, 5))