Python's Zip function

Welcome to part 8 of the intermediate Python programming tutorial series. In this part, we're going to talk about the built-in function: zip.

The zip function iterates through multiple iterables, and aggregates them. Consider you have two lists, and you instead want them to be one list, where elements from the shared index are together. While simple, there are a few important notes to make when working with it!

Now, using zip, let's illustrate a potential issue that you might run into.

The main take-away is the difference between list comprehension, and a typical for loop. It can be very easy to just run through your old code, and change all for loops to list comprehension. If you were using bad practices, however, this can cause you some trouble! Let's see an example!