Categories
Python Answers

How to zip lists in Python?

Spread the love

Sometimes, we want to zip lists in Python.

In this article, we’ll look at how to zip lists in Python.

How to zip lists in Python?

To zip lists in Python, we can call the zip method with multiple lists.

For instance, we write

a = b = c = range(20)

l = zip(a, b, c)

to call zip with lists a, b, and c.

Then we get a list with tuples with the items from each list at the position of the of the tuple in the returned list/

Conclusion

To zip lists in Python, we can call the zip method with multiple lists.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *