Skip to content

Instantly share code, notes, and snippets.

@sethbunke
Created May 25, 2017 01:05
Show Gist options
  • Save sethbunke/61561629f3dea612af6dad2cc02a46bc to your computer and use it in GitHub Desktop.
Save sethbunke/61561629f3dea612af6dad2cc02a46bc to your computer and use it in GitHub Desktop.
Identify duplicate values in an array
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