how to make ["a","b",["c","d"],"e"] into ['a', 'b', 'c', 'd', 'e'] ?

balaji marisetti balajimarisetti at gmail.com
Thu Apr 10 01:25:10 EDT 2014


There was long thread discussing flattening of a list on this list :).
See the link below.

https://mail.python.org/pipermail/python-list/2014-March/669256.html

On 10 April 2014 10:44, length power <elearn2014 at gmail.com> wrote:
>>>> x=["a","b",["c","d"],"e"]
>>>> y=x[2]
>>>> y
> ['c', 'd']
>>>> x.insert(2,y[0])
>>>> x
> ['a', 'b', 'c', ['c', 'd'], 'e']
>>>> x.insert(3,y[1])
>>>> x
> ['a', 'b', 'c', 'd', ['c', 'd'], 'e']
>>>> del x[4]
>>>> x
> ['a', 'b', 'c', 'd', 'e']
>>>>
> maybe there is a more smart way to do.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
:-)balaji



More information about the Python-list mailing list