Created
May 3, 2019 09:56
-
-
Save antimirov/1bb5ea36e78692f04dbb33cf376ce2bc to your computer and use it in GitHub Desktop.
Flatten a python list of arbitrary nesting
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
| def flatten(arr): | |
| for i in arr: | |
| if isinstance(i, list): | |
| yield from flatten(i) | |
| else: | |
| yield i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment