Skip to content

Instantly share code, notes, and snippets.

@HaloZero
Created April 14, 2016 22:34
Show Gist options
  • Save HaloZero/1911f31f6a64320a4e1c25c38fee16ca to your computer and use it in GitHub Desktop.
Save HaloZero/1911f31f6a64320a4e1c25c38fee16ca to your computer and use it in GitHub Desktop.
def flatten(arr):
new_array = []
for element in arr:
if isinstance(element, list):
new_array.extend(flatten(element))
else:
new_array.append(element)
return new_array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment