2

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.

wjandrea
  • 23,210
  • 7
  • 49
  • 68
olo
  • 61
  • 6

1 Answers1

0
lst=['A','B',['ABB','ADE'],'Z','!@#',['UU','II']]
new_list = []
for item in lst:
    new_list.extend(item)
print(new_list)
akaButters
  • 180
  • 9