-1

I have a different case of list Flattening.

Suppose I have a list of list ,say l=[['a'],[['p','l']]] . I simply want ['a',['p','l']]. That is the single elements should not be in nested lists and the lists having more than one element can be nested twice.

Thanks

Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
Pooja
  • 23
  • 1
  • 4

1 Answers1

0

Seems like you want something like this

In [4]: l=[['a'],[['p','l']]]

In [5]: [j for i in l for j in i]
Out[5]: ['a', ['p', 'l']]
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274