Skip to content

Instantly share code, notes, and snippets.

@gdsaxton
Created March 15, 2018 18:08
Show Gist options
  • Save gdsaxton/90b4d2434ec3e7de1fa30f7c47770295 to your computer and use it in GitHub Desktop.
Save gdsaxton/90b4d2434ec3e7de1fa30f7c47770295 to your computer and use it in GitHub Desktop.
Find Duplicates in List, Take 2
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import collections\n",
"mylist = ['twitter', 'facebook', 'instagram', 'twitter']\n",
"[item for item, count in collections.Counter(mylist).items() if count > 1]"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [default]",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.13"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment