Skip to content

Instantly share code, notes, and snippets.

@stephengruppetta
Created December 7, 2023 09:33
Show Gist options
  • Save stephengruppetta/6ff6987596bef1a5b3921daa97b41c92 to your computer and use it in GitHub Desktop.
Save stephengruppetta/6ff6987596bef1a5b3921daa97b41c92 to your computer and use it in GitHub Desktop.
import itertools
some_names = [
"Robert",
"Ishaan",
"Max",
"Trevor",
"Alexandra",
"Albert",
"Christine",
]
output = itertools.groupby(
some_names,
key=len,
)
for item, group in output:
print(item, list(group))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment