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
  • 28,235
  • 9
  • 60
  • 81
olo
  • 133
  • 1
  • 7

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
  • 375
  • 1
  • 12