Created
May 25, 2017 01:05
-
-
Save sethbunke/61561629f3dea612af6dad2cc02a46bc to your computer and use it in GitHub Desktop.
Identify duplicate values in an array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
input = [1,2,3,2,1,5,6,5,5,5] | |
result = [item for item, count in collections.Counter(input).items() if count > 1] | |
print(result) | |
#[1, 2, 5] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment