Hello all,
I am trying to make a loop that compares many different lists to see if there is any overlap/matching elements in them. Once a match is identified I would like to move onto the next list to see if there's a match. The problem is at the moment it is not stopping once it reaches a match it keeps going and printing as long as k==l. I tried putting break in but then it doesn't save my list. I would like a new list every time there's a match, because any vector that overlaps with another needs to be in its own list. I hope someone understands me and can help!?
I am trying to make a loop that compares many different lists to see if there is any overlap/matching elements in them. Once a match is identified I would like to move onto the next list to see if there's a match. The problem is at the moment it is not stopping once it reaches a match it keeps going and printing as long as k==l. I tried putting break in but then it doesn't save my list. I would like a new list every time there's a match, because any vector that overlaps with another needs to be in its own list. I hope someone understands me and can help!?
A=[] for k in range(int(sRegions[0,0]),int(sRegions[0,1])): for l in range(int(sRegions[1,0]),int(sRegions[1,1])): if k == l: A.append(sRegions[0,:]) print (A) break break break