Let's say I have this list with size equal to 10 :
List=[0,2,3,7,6,8,9,15,20,30,40]
I want to reduce the size of the list to a fixed one. For this example let's say to 4. Since python does not support float slice indices, is there a workaround to extract elements of this list every 10/4=2.5 element.
I would like a result that looks like this for example:
New_List =[0,6,15,40]
I tried this :
New_List = [n for k,n in enumerate(List) if k+1 in [1, round(len(List)*0.33), round(len(List)*.66), len(List)]]
This only extracts 4 elements. The new size can change and can be bigger than 4 so I want a better workaround to extract elements of this list every x element where x is a float.