Return sublists of List of lists

后端 未结 4 410
盖世英雄少女心
盖世英雄少女心 2021-01-22 13:45

Well, I have this example:

mylist = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4,          


        
4条回答
  •  粉色の甜心
    2021-01-22 14:32

    You should probably use generators for the inner lists as well, if you are trying to get the process to scale :

    g = lambda k: (k[i] for i in range(5))
    for x in mylist:
        yield g(x)
    

提交回复
热议问题