how to split nested list containing strings with python3

Viewed 33

I have a nested list:

lst=['A','B',['ABB','ADE'],'Z','!@#',['UU','II']]

how to deal with ['ABB','ADE'], ['UU','II']so that I got:

lst=['A','B','ABB','ADE','Z','!@#','UU','II']

tried many methods but not working. The order should NOT be the changed.

1 Answers
lst=['A','B',['ABB','ADE'],'Z','!@#',['UU','II']]
new_list = []
for item in lst:
    new_list.extend(item)
print(new_list)
Related