Skip to content

Instantly share code, notes, and snippets.

def flatten(nested, result):
for elem in nested:
if isinstance(elem, list):
flatten(elem, result)
else:
result.append(elem)
nested_array = [[1, 2, [3, 4], 5], [6, 7]]
result = []
flatten(nested_array, result)

Keybase proof

I hereby claim:

  • I am davkhech on github.
  • I am davkhech (https://keybase.io/davkhech) on keybase.
  • I have a public key whose fingerprint is CCE9 7C7D 25A8 1B28 6B7B A1F7 6F84 99C1 2969 D0B7

To claim this, I am signing this object: