Skip to content

Instantly share code, notes, and snippets.

@alexwoolford
Created November 7, 2014 04:34
Show Gist options
  • Save alexwoolford/fbc93a96bcce4c04f6cd to your computer and use it in GitHub Desktop.
Save alexwoolford/fbc93a96bcce4c04f6cd to your computer and use it in GitHub Desktop.
List comprehension and sets
# coding: utf-8
# http://stackoverflow.com/questions/26794029/how-to-remove-duplicate-letters-in-a-comma-separated-cell
# In[1]:
text = """A,B,B,C
G,G,A,T
G,A,A
T,T"""
# In[2]:
[",".join(set(commaChars.split(','))) for commaChars in text.split('\n')]
# Out[2]:
# ['A,C,B', 'A,T,G', 'A,G', 'T']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment