Created
July 28, 2015 06:26
-
-
Save monkeymantra/cb80716981b35fe4cbab to your computer and use it in GitHub Desktop.
flatten
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
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