Skip to content

Instantly share code, notes, and snippets.

@indapa
Created March 8, 2013 21:14
Show Gist options
  • Save indapa/5119913 to your computer and use it in GitHub Desktop.
Save indapa/5119913 to your computer and use it in GitHub Desktop.
Flatten a list of lists with itertools
#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