Question:

Write a python program to show the difference in zip() and izip() function

Explanation:

zip() is a standard library which combines elements into tuples.

The izip() function works the same way, but it returns an iterable object for an increase in performance by reducing memory usage.

We can directly print the list returned by zip() but, we cannot directly print an iterable object. We need to use next(iterable_object) or a loop.

Lists are stored in memory so they have the advantage of faster access times over Iterable Object whose contents are not entirely stored in memory but fetched on-demand instead.

Program:

Output:
Do share your feedback in comments to help us adding more programs like this.

Checkout more Python Programs

Click here

Leave a Reply