Get a driver's-eye view of other cars driving along the 110 Freeway in Los Angeles as they pass under the soaring interchange with the 105 Freeway. This is quintessential L.A. architecture and a typical view for thousands of people every commute.  Another sunny day in paradise.
Photo by Chris Linnett on Unsplash

Two of the most common data structures in Python are lists and dictionaries. If you take a look back at your code, you may notice that you have a lot of lists and dictionaries used all over the place.

They may look quite similar, but they have a key difference. You can think of a list as a collection of items, and a dictionary as a collection of key-value pairs.

There can be cases when you may need to do a conversion of 2 lists into a single dictionary. This is something that you can easily do in Python with the help of zip() function.

First, let’s take a look at 2 lists:

first = [“name”, “surname”, “city”]
second = [“Durim”, “Gashi”, “New York”]

Now, we can simply call the zip() function:

Yes, it’s that easy.

Note that you can use this even if you have duplicate elements or one of the lists has more elements than the other one, for example: