prune = lambda tree : [prune(branch) for branch in tree if branch != []] l = [[[[], []], [[], []]], [[], [], []]] prune(l)
def prune(tree): for branch in tree: if branch!=[]: prune(branch) return branch print prune([[[[], []], [[], []]], [[], [], []]])
def prune(tree): result = [] for branch in tree: if branch != []: result.append(prune(branch)) return result
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)