Also, imagine we have list that we need to disassemble a list and split it into 4 different lists like these:
[1, 5, 9]
[2, 6, 10]
[3, 7, 11]
[4, 8, 12]
Then we should do the following
params = [0.25, 0.5, 0.75, 1] a_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] step = 4 for i in range(len(params)): element = a_list[i::step] print(element)
Use the extended slicing syntax a_list[start:stop:step]
to get a new list containing every nth element.