Mar-20-2019, 04:00 PM
L1 = [[1,2,3],[4,2],[6,8,1],[4,3]] L2 = [1,2,3,4,5,6,7,8,9,10] L3 =[] def ListStrcCopy(L1,L2): L = [] for i in L1: L.append (L2.pop(0)) return L for i in L1: L3.append(ListStrcCopy(i,L2)) print (L3)I'm trying to copy the list structure from L1 to L2. The new list is [[1, 2, 3], [4, 5], [6, 7, 8], [9, 10]]. The script above achieved the goal, but I'm seeking for a simpler way to do that.
Thanks!