Skip to content

Instantly share code, notes, and snippets.

#Input Variable
nestedX = [[[[[1, 2, [[[3]]]], 4]]]]
#Recursive function written quickly.
def flatten(nX):
flatX = []
for x in nX:
if isinstance(x,int):
flatX += [x]
else: