Skip to content

Print zip object Python

  • by

Use the print() function with a list() class to convert the zip object (iterator) to a list and print in Python. To print a zipped list:

  1. Use the zip() function to get an iterator of tuples.
  2. Use the list() class to convert the iterator to a list.
  3. Use the print() function to print the list.

Print zip object Python

Simple example code.

list_1 = [1, 2, 3]
list_2 = ['X', 'Y', 'Z']

my_list = list(zip(list_1, list_2))

print(my_list)

Output:

Print zip object Python

Python range() and zip() object type

In Python 3.x., range returns a range object instead of a list like it did in Python 2.x. Similarly, zip now returns a zip object instead of a list.

range(10)
range(0, 10)
print(list(range(10)))

print(zip('abc', 'abc'))

print(list(zip('abc', 'abc')))

Output:

Python range() and zip() object type

Do comment if you have any doubts or suggestions on this Python zip topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

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