Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make zip_longest available in itertools using Python 2.7

When trying to import this function on a Python Jupyter 2.7 nb running on Windows 10, I get this error:

enter image description here

I believe I hadn't encountered problems in the past because I was using Python 3. So I wonder if it is just that it is not available in Python 2, or if there is a way of making it work.

like image 228
Antoni Parellada Avatar asked Jun 10 '17 21:06

Antoni Parellada


1 Answers

For Python 3, the method is zip_longest:

from itertools import zip_longest

For Python 2, the method is izip_longest:

from itertools import izip_longest
like image 54
Ajax1234 Avatar answered Oct 02 '22 13:10

Ajax1234