Skip to content

Instantly share code, notes, and snippets.

@monkeymantra
Created July 28, 2015 06:26
Show Gist options
  • Save monkeymantra/cb80716981b35fe4cbab to your computer and use it in GitHub Desktop.
Save monkeymantra/cb80716981b35fe4cbab to your computer and use it in GitHub Desktop.
flatten
import itertools
def flatten(l):
if type(l) != list:
return l
else:
return list(itertools.chain(*map(flatten, l)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment