Convert list into list of lists

前端 未结 3 1328
攒了一身酷
攒了一身酷 2020-11-29 08:52

I want to convert list into list of list. Example:

my_list = [\'banana\', \'mango\', \'apple\']

I want:

my_list = [[\'banan         


        
3条回答
  •  悲&欢浪女
    2020-11-29 09:23

    Try This one Liner:-

    map(lambda x:[x], my_list)
    

    Result

    In [1]: map(lambda x:[x], my_list)
    Out[1]: [['banana'], ['mango'], ['apple']]
    

提交回复
热议问题