0

How to unpack a list, which is nested inside another list. Practically to transform this:

l=['aa','bb',['ccc','ddd'],'ee'] 

to

l=['aa','bb','ccc','ddd','ee']
1

1 Answer 1

1

See this thread and e. g. the solution of elqott

>>> from compiler.ast import flatten
>>> l = ['1','2',['3','4'],'5'] 
>>> flatten(l)

Following your edit

['1', '2', '3', '4', '5']
>>> l = ['aa','bb',['ccc','ddd'],'ee'] 
>>> flatten(l)
['aa', 'bb', 'ccc', 'ddd', 'ee']
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.