So I have this list containing tuples, and I have also written a code which calculates the Euclidean distance between any two tuples in that list. I’m having problems writing a code which calculates every possible pair of tuples =S I know that there’s a lot of similar questions and many suggested using itertools, but I’m not familiar with that and would like a regular looping code if possible. But itertools would be cool if someone could teach me 🙂
Basically my list looks like
[(1,2,3,4),(5,6,7,8)(9,10,11,12)....etc]
and my distance coding is working fine. Just the choosing part I’m having problems with. Thank you!
Edit: Sorry, forgot to mention, so I want the sum of all the distances of ALL the possible pairs. To recap, I have like 100 tuples in that list, I want to calculate distance between tuple1/tuple2, tuple1/tuple3,…tuple99/tuple100, and sum all of that and put it into a list.
Hope this is clear!
Here’s a simplified example using
itertools:Output:
Then perform any calculation you want on those…