-
-
Save stephengruppetta/6fe7870ff1787d6791ed0d52c1f9af83 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( | |
sorted( | |
some_names, | |
key=len, | |
), | |
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