summaryrefslogtreecommitdiff
path: root/comp/work/47/flatten.py
blob: 2e1958c4fb56442d833c2e6ee98200e6cca34cf2 (plain)
1
2
3
4
5
6
7
8
9
10
def flatten(l):
    out = []
    for i in l:
        if hasattr(i, "__len__"): 
            for j in flatten(i): out.append(j)
        else: out.append(i)

    return out

print(flatten([1, [[4, 6], 5], 2]))