IntermediateChallenge 20 of 34

Group anagrams

Write group_anagrams(words) that groups words which are anagrams of each other. Return a of groups (each a list, in original order), with the groups ordered by their first appearance.

Examples
group_anagrams(["eat", "tea", "tan", "ate", "nat", "bat"]) → [["eat", "tea", "ate"], ["tan", "nat"], ["bat"]]
Exercise

Group anagrams

3 checks
def group_anagrams(words):
    ...


print(group_anagrams(["eat", "tea", "tan", "ate", "nat", "bat"]))
 
Python (loads on first run)Ctrl+Enter runs
Output
Press Run to try your code, then Check answer to grade it.