-
-
Save stephengruppetta/6ff6987596bef1a5b3921daa97b41c92 to your computer and use it in GitHub Desktop.
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
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