d = [[1, 5, 8, 3], [2, 2, 3, 9], [3, 2, 4, 6]] rezip(d): [(1, 2, 3), (5, 2, 2), (8, 3, 4), (3, 9, 6)] If a =[1, 5, 8], b=[2, 2, 3], c=[3, 2, 4] then it's eazy to: zip(a,b,c) = [(1, 2, 3), (5, 2, 2), (8, 3, 4)] But it's hard for d = [[1, 5, 8], [2, 2, 3], [3, 2, 4]]
(aList)
| 131 | |
| 132 | #======================================================================== |
| 133 | def rezip(aList): |
| 134 | ''' d = [[1, 5, 8, 3], [2, 2, 3, 9], [3, 2, 4, 6]] |
| 135 | rezip(d): |
| 136 | [(1, 2, 3), (5, 2, 2), (8, 3, 4), (3, 9, 6)] |
| 137 | |
| 138 | If a =[1, 5, 8], b=[2, 2, 3], c=[3, 2, 4] |
| 139 | then it's eazy to: zip(a,b,c) = [(1, 2, 3), (5, 2, 2), (8, 3, 4)] |
| 140 | |
| 141 | But it's hard for d = [[1, 5, 8], [2, 2, 3], [3, 2, 4]] |
| 142 | ''' |
| 143 | |
| 144 | tmp = [ [] for x in range(len(aList[0])) ] |
| 145 | for i in range(len(aList[0])): |
| 146 | for j in range(len(aList)): |
| 147 | tmp[i].append(aList[j][i]) |
| 148 | return tmp |
| 149 | |
| 150 | #======================================================================== |
| 151 | def sumInList(complexList): |