I would like to compare the elements of a list, and at the end of each for
loop the combination resumes with the new updated list.
from itertools import combinations
aListe = ['a', 'b', 'c', 'd']
for first, second in combinations(aListe, 2):
# do something
aListe.remove(first)
ValueError: list.remove(x): x not in list
more specific example of the # do something.
Imagine my list contains shapely polygon such as
aListe = [polygon1, polygon2, polygon3, polygon4]
for first, second in combinations(aListe, 2):
if area(first) > area(second):
aListe.remove(first)
if the area of the first polygon in the list is already greater than the second I don't want it to be compared to the others. I would like the next for
loop start on an updated list without the first polygon.