how to make this situation return this result?

breamoreboy at gmail.com breamoreboy at gmail.com
Sat Jul 1 11:15:49 EDT 2017


On Saturday, July 1, 2017 at 1:46:21 PM UTC+1, Ho Yeung Lee wrote:
> just want to compare tuples like index (0,1), (0,2), (1,2) without duplicate
>  such as (2,0), (1,0) etc
> 

I'm still not entirely sure what you're asking, but can't you just generate what you want with itertools combinations, something like:-

>>> import itertools
>>> tuples = list(itertools.combinations(range(3), 2))
>>> tuples
[(0, 1), (0, 2), (1, 2)]



More information about the Python-list mailing list