Skip to content

Instantly share code, notes, and snippets.

@pdxwebdev
Created March 10, 2016 16:23
Show Gist options
  • Save pdxwebdev/50b06b85dc951eb77e63 to your computer and use it in GitHub Desktop.
Save pdxwebdev/50b06b85dc951eb77e63 to your computer and use it in GitHub Desktop.
asdf
test_array = [[1,2,[3]],4]
test_array2 = [[1,2,[3]],[[5,6,[[78]],4]]]
test_array3 = [[1,2,[3]],[[[4]]]]
def flatten(input_array):
newArray = []
if type(input_array) == type([]):
for item in input_array:
newArray.extend(flatten(item))
else:
return [input_array]
return newArray
flatten(test_array)
flatten(test_array2)
flatten(test_array3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment