1 2 3 4 5 6 7
#!/usr/bin/env python2 a=[1,2,3,4,5,6,7,8,9,10] b=[(a[i], a[j]) for i in range(len(a)) for j in range(i+1,len(a))] print len(b)