Python List using zip()

  • Post category:List

The zip() function takes iterables (can be zero or more), aggregates them in a tuple, and return them.

In this blog post, you will learn how to code a python list using zip() function.

Step 1: Create a list

my_list = [1, 2, 3, 4, 5]

Step 2: Print the list

for i, j in zip(range(2,5), my_list):
  print(i, j)

Output:

2 1
3 2
4 3