I have a VERY long list of tuples e.g. [(1,2), (18,485), (284,475)....]. I also have a for loop, which will perform a function on groups of these tuples. I want the loop to be executed on the first 68 tuples, then the next 68 tuples, then the next 68 tuples, and so on until it has been done on all tuples (the total number of tuples is divisible by 68, by the way).
I thought first to group the tuples into separate lists of 68, but then wondered if it is more efficient to do something using the "in range(68)" function? I just do not know how to get the for loop to then move onto the next set of 68 tuples and to not re-read the first 68 tuples.
I do not yet have much code, just
tuple1= new_tuple # changing tuple of tuples to list of tuples
list_of_tuples = list(tuple1)
# here I want to either split the list into mini-lists of 68, or start the for loop for the first 68 tuples, then the next 68 etc.
#the for loop:
for z in SOMETHING?
d = z
mdata = []
for p, k in combinations(d,2):
distance = math.sqrt( ((p[0]-k[0])**2)+((p[1]-k[1])**2) )
mdata.append(distance)
I dont think this helps much though. Would really appreciate any help or even just advice. Thanks in advance.