I came up with these simple solutions to RonJeffries‘ CodingProblem. The first uses Python 2.2’s generators, the second uses the functional idiom, and the third uses list comprehensions. The third is my favorite:
def split1(list, num) : for index in range(num) : yield list[index * len(list) / num:(index + 1) * len(list) / num] def split2(list, num) : return map(lambda x: list[x * len(list) / num:(x+1) * len(list) / num], range(num)) def split3(list, num) : return [list[x*len(list)/num : (x+1)*len(list)/num] for x in range(num)]