Last active
December 27, 2021 04:24
-
-
Save SergioJuniorCE/daf4b263d076a74eefaebf580d07c478 to your computer and use it in GitHub Desktop.
add every different thing until run out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
indexes = [] # 0, 6, 9 | 20 | |
for i, item in enumerate(items): | |
if i == 0: | |
indexes.append(i) | |
continue | |
if i+1 == len(items): | |
break | |
if item[1] != items[i+1][1]: | |
indexes.append(i+1) | |
groups = [] | |
for i, index in enumerate(indexes): | |
if i == len(indexes) - 1: | |
groups.append(items[index:len(items)]) | |
else: | |
groups.append(items[index:indexes[i+1]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment