Skip to content

Instantly share code, notes, and snippets.

@SergioJuniorCE
Last active December 27, 2021 04:24
Show Gist options
  • Save SergioJuniorCE/daf4b263d076a74eefaebf580d07c478 to your computer and use it in GitHub Desktop.
Save SergioJuniorCE/daf4b263d076a74eefaebf580d07c478 to your computer and use it in GitHub Desktop.
add every different thing until run out
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