Python- Count each letter in a list of words

后端 未结 7 1524
心在旅途
心在旅途 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:22

    cnt = Counter()
    for words in wordList:
          for letters in set(words):
              cnt[letters]+=1
    

提交回复
热议问题