Python Lists - Finding Number of Times a String Occurs

后端 未结 8 473
独厮守ぢ
独厮守ぢ 2020-12-10 17:21

How would I find how many times each string appears in my list?

Say I have the word:

\"General Store\"

that is in my list like 20 t

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-10 17:31

    Use the count method. For example:

    (x, mylist.count(x)) for x in set(mylist)
    

提交回复
热议问题