Zipping up in Python

Multiple iterables like lists, tuples, dictionaries, etc. can be zipped up in Python using the zip() function. What does it mean and how does it work? Let’s take a quick look:
Zip function takes multiple iterables as arguments and returns an iterator in form of multiple tuples. For example, consider 3 lists:

a = [1,2,3]
b = [x,y,z]
c = [4,5,6]

Now, these 3 lists can be zipped up and actions can be performed on them parallely. Zip() takes element from each iterable and puts them in tuples. Then, we can make an iterator out of it by passing the zipped object into another list, set, dictionary, etc.


[ (1,x,4) , (2,y,5) , (3,z,6) ]
With these iterable tuples, many operations can be performed parallely, such as: arithmetic operations, comparing the iterables, traversing and creating dictionaries, sorting, and much more.:zap:

I used lists for passing iterables and generating the final zipped iterator. However, any iterable can be used here.

So, this was Zipping.
Now a question for you, how do we unzip?:thinking:

#python #datascience