Created
March 8, 2013 21:14
-
-
Save indapa/5119913 to your computer and use it in GitHub Desktop.
Flatten a list of lists with itertools
This file contains hidden or 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
#see http://stackoverflow.com/a/952952/1735942 | |
import itertools | |
genotypes=['GG', 'GT', 'GG'] | |
alleles= [ list(tuple(g)) for g in genotypes ] | |
print alleles | |
alleles=list(itertools.chain.from_iterable(alleles)) | |
print alleles |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment