LoginSignup
2
2

More than 5 years have passed since last update.

listから重複がある要素を探す

Posted at

色々方法あるんだろうけど。

>>> from collections import Counter
>>> [ k for k, v in Counter([0,1,2,3,2,0,4]).items() if v > 1 ]
[0, 2]
>>> [ k for k, v in Counter("abcefacc").items() if v > 1 ]
['c', 'a']
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2