Finding the most popular words in a list

前端 未结 3 1033
我寻月下人不归
我寻月下人不归 2021-02-05 22:32

I have a list of words:

words = [\'all\', \'awesome\', \'all\', \'yeah\', \'bye\', \'all\', \'yeah\']

And I want to get a list of tuples:

3条回答
  •  野的像风
    2021-02-05 23:00

    Is it Pythonic, elegant and efficient?

    Looks good to me...

    Are you able to do it better?

    "better"? If it's understandable, and efficient, isn't that enough?

    Maybe look at defaultdict to use that instead of setdefault.

提交回复
热议问题