Removing the nested list

D = []
def move_list(a):
    for i in a :
        if type(i) != list:
            D.append(i)
        else:
            move_list(i)
s=[1,[12,[1,[1,23,4,[1,2,[3]]]]],[3,[1,[2,645,[3,5,[456,[4,[45,7,[2,[[[[[[5]]]]]]]]]]]]],4]]
move_list(s)
print(D)

 

Guess you like

Origin www.cnblogs.com/aj-AJ/p/11534028.html