Iterating portions of lists - PYTHON -


bit of generic noob question. heavily dealing long lists of integer/float values , wasting lot of time.

my_list = [1,2,3,4,5,6,7,8,9,10.....] etc. 

say want pass portion of list function. first 3 elements, following 3 etc....it in groups of 4,5,6....it might required take different different amount of elements each time.

def myfunc(x,y,z):   return 

what efficient way iterate specified number of values, efficiency appreciated , these simple iterations places can gain something.

len_ml = len(my_list) in range(0, len_ml, 3):   chunk = my_list[i:min(len_ml, i+3)] 

this way. not sure best, though.


Comments