for i in rangen for j in rangelenlists groupsjappendlistsji
This code creates a list of groups, with each group containing one element from each list in the input lists. The variable n is assumed to be the length of the shortest list in lists.
The outer loop iterates n times, and the inner loop iterates over each list in lists. For each iteration of the outer loop, the inner loop appends the ith element of the jth list in lists to the jth group in groups.
For example, if the input lists is [[1,2,3],[4,5,6],[7,8,9]], then the output groups would be [[1,4,7],[2,5,8],[3,6,9]].
原文地址: http://www.cveoy.top/t/topic/brPC 著作权归作者所有。请勿转载和采集!