Python- Count each letter in a list of words

后端 未结 7 1575
心在旅途
心在旅途 2021-01-16 05:46

So I have a list of words `wordList = list().\' Right now, I am counting each letter in each of the words throughout the whole list using this code

cnt = C         


        
7条回答
  •  春和景丽
    2021-01-16 06:12

    cnt = Counter()
    for word in wordList:
        lSet = set(word)
        for letter in lSet:
            cnt[letter] +=1             
    

提交回复
热议问题