Code:
from itertools import productfor px, opx in product(bodies, bodies[1:]): print(px, opx) # or if you want AA, AB, AC, Ba, BB, BC, ....for px, opx in product(bodies, repeat=2): print(px, opx)And if you want to have an index during iteration, you should use enumerate.
If you don't need an index, work with the objects directly, instead of using an index to access single objects in the sequence. This is a known antipattern and looks not pythonic.
Statistics: Posted by DeaD_EyE — Sun Feb 15, 2026 10:10 am