Suppose, I have a sorted list with 2000 elements. List elements may contain duplicate or same value. Now I want to make 74 sub list where every sub list will contain 27 elements (number of sub list and number of containing elements may vary according to users' choice). Every sub list will give same average value. Lets I have a value[2000] list-
# value list having 2000 elements
value = [ 3.3, 3.4, 3.4, ...., 4.1, 4.1, 4.2, ....., 5.1, 5.2, 5.2, .... 6.3, 6.3,...., 6.6]
Now I want to make 74 sub list with each 27 elements (74*27 = 1998 list elements will be used from value[] list which contains 2000 elements)
My expecting result will be-
# every sub_list having 27 elements
sub_list_1 = [ 3.4, 3.4,...., 4.1,..., 4.2,...., 5.2, ...., 6.3,..., 6.6]
average_value = sum(sub_list_1)/27 = 4.5
............................
............................
sub_list_74 = [ 3.3,...., 4.4,..., 4.9,...., 5.2, ....,]
average_value = sum(sub_list_74)/27 = 4.5
How can I do this with Python? Please explain details....