Skip to content

Instantly share code, notes, and snippets.

On vacation

Tharun Kumar Reddy tharun323

On vacation
  • Chennai
Block or report user

Report or block tharun323

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
tharun323 / gist:59827582ba22a32c2fb72675b380e9aa
Created Jun 14, 2018
Code,that will flatten an array of arbitrarily nested arrays of integers into a flat array of integers
View gist:59827582ba22a32c2fb72675b380e9aa
flatten = lambda x: [y for l in x for y in flatten(l)] if type(x) is list else [x]
a = [1, 2, [3, 4], [[5, 6], [7, 8]]]
print flatten(a)
# This will print a list [1, 2, 3, 4, 5, 6, 7, 8]
You can’t perform that action at this time.