For a recent project I used groupby from itertools.
I had to check the label of the first object that the groupby returns.
My first guess was:
from itertools import groupby groups = groupby("00001110000111") print(groups)
TypeError: 'itertools.groupby' object has no attribute '__getitem__'
my second guess was using next:
from itertools import groupby groups = groupby("0001110000111") print(next(groups))
And worked! The first element is now gone without return and all next accesses of groups refer to the remaining elements.