Created
November 7, 2014 04:34
-
-
Save alexwoolford/fbc93a96bcce4c04f6cd to your computer and use it in GitHub Desktop.
List comprehension and sets
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
# 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