我有这个字谜单词列表,如果它们具有相同的字母,我想将它们拆分为嵌套列表。
mylist = ["pots", "stop", "levi", "vile", "evil", "spot", "star", "rats", "bingo", "live", "tops" "gobin"]
结果:
anagrams = [["pots", "stop", "spot", "tops"],
["levi", "live", "vile", "evil"],
["star", "rats"],
["bingo", "gobin"]]
我想使用纯 python 拆分它们,即不使用任何 python 包,例如来自 itertools 的 groupby
很感谢任何形式的帮助。