top of page

finding duplicates with python

You can use the below python script to find where there are duplicates in a character set.


First open a Python IDLE shell window and enter this code:


>>> def find_duplicates(s):

elements = {}

for char in s:

if elements.get(char,None) != None:

elements[char]+=1

else:

elements[char] = 1

return [k for k,v in elements.items() if v>1]


Then enter the set of characters you want to search using the print command and the command created by this code

>>> print(find_duplicates("ATRZSWAPOS"))


After this is saved, Python will give you the result shown below.




Sean O'Shea has more than 20 years of experience in the litigation support field with major law firms in New York and San Francisco.   He is an ACEDS Certified eDiscovery Specialist and a Relativity Certified Administrator.

The views expressed in this blog are those of the owner and do not reflect the views or opinions of the owner’s employer.

If you have a question or comment about this blog, please make a submission using the form to the right. 

Your details were sent successfully!

© 2015 by Sean O'Shea . Proudly created with Wix.com

bottom of page