Skip to content

Instantly share code, notes, and snippets.

@yjzhang
Created November 18, 2018 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yjzhang/b9d26f6bf5dd07b79b9c9a909a3c2904 to your computer and use it in GitHub Desktop.
Save yjzhang/b9d26f6bf5dd07b79b9c9a909a3c2904 to your computer and use it in GitHub Desktop.
flattening a list in python
def flatten(l):
output = []
for x in l:
try:
output += flatten(x)
except:
output.append(x)
return output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment