def myLists(L): final_list=[] sub_list=[] for each in L: sub_list[:]=[] for num in range(0, each+1): sub_list.append(num) final_list.append(sub_list[1:]) return final_list L=[1,2,4,5,7]nl= myLists(L)print nl
Standard input is empty
[[1], [1, 2], [1, 2, 3, 4], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6, 7]]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!