If I understand the task at hand correctly then groupby can be used:
If groups are large then indices can be obtained without unpacking
>>> data = [0,1,1,1,1,2,2,2,85,85,85,80,80,80,0,1,1,1,2,2,2,85,95,80,80,80] >>> [[*group][0][0] for match, group in groupby(enumerate(data), key=lambda digit: digit[1] == 85) if match == True] [8, 21] # index of first 85 in groupEDIT:
If groups are large then indices can be obtained without unpacking
next(group)[0]
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.