I'm trying to write a code that could divide a list into smaller lists, as follows, I have a list and a value like that:
nb_classes = [1, 2, 3, 4, 5, 6, 7, 8, 9]
N = 3
I want to get smaller N
lists depends on the length of nb_classes
and the value of N
.
If the value of N
is 3 for example, I want to have 3 small lists like that :
nb_classes = [1, 2, 3, 4, 5, 6, 7, 8, 9]
list_1 = [1,2,3]
list_2 = [4,5,6]
list_3 = [7,8,9]
Second example :
nb_classes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
list_1 = [1,2,3,4]
list_2 = [5,6,7]
list_3 = [8,9,10]
Third example :
nb_classes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
list_1 = [1,2,3,4]
list_2 = [5,6,7,8]
list_3 = [9,10,11]
Thank you.