Dec-05-2017, 04:17 PM
I would like to take a string and divide it into segments and came across this 'recipe' in the docs for zip_longest. However, I'm not getting the output I was expecting, which would be something like: abc def ghi
from itertools import zip_longest def grouper(iterable, n, fillvalue=None): args = [iter(iterable)] * n return zip_longest(*args, fillvalue=fillvalue) # a_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'] a_str = 'abcdefghi' a = grouper(a_str, 3) print(a)Instead I get:
Output:<itertools.zip_longest object at 0x000002094F398CC8>
Am I missing something here?
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition