mycode  95.35%

思路:构建字典

class Solution(object):
    def groupAnagrams(self, strs):
        """
        :type strs: List[str]
        :rtype: List[List[str]]
        """
        dic = {}
        for item in strs:
            temp = ''.join(sorted(item))
            if temp not in dic:
                dic[temp] = [item]
            else:
                dic[temp].append(item)
        return list(dic.values())
        

下面是list的加法

if temp not in dic:
dic[temp] = [item]
else:
dic[temp] += [item]

    if temp not in dic:
                dic[temp] = [item]
    else:
                dic[temp] += [item]