Skip to content

Instantly share code, notes, and snippets.

@Makistos
Created June 27, 2016 12:43
Show Gist options
  • Save Makistos/f7ba2e279e38019be0d0531b0f0a8a98 to your computer and use it in GitHub Desktop.
Save Makistos/f7ba2e279e38019be0d0531b0f0a8a98 to your computer and use it in GitHub Desktop.
Flattening a list in Python. #python
def flatten(coll):
for i in coll:
if isinstance(i, (list, tuple)):
for j in flatten(i):
yield j
else:
yield i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment