but: li = [grp for k, grp in groupby("aahfffddssssnnb")] list(li[0]) [] list(li[1]) [] It seems empty ... I don't understand why, this is the first read of an iterator, it should provide its data.
The group-iterators are connected. Each group-iterator is a wrapper around the original iterator with an extra termination condition. So in order to start the next group-iterator the previous group-iterator is exhausted, because the original iterator has to be ready to produce values
for the next group-iterator. -- Antoon Pardon. -- https://mail.python.org/mailman/listinfo/python-list