I made the mistake of using permutations instead of combinations, i am supposed to print the names the user enters in this programs in pairs of two, not all the permutations of the names together, here is a snippet of my code, the full code can be found HERE So the general question is instead of printing out every name combination possible, how can i print non repeated pairs of 2?
names = []
for i in range(n): names.append(raw_input("Enter name " + str(i + 1) + ": "))
count = 0
def perm(a, k=0):
global count
if (k == len(a)):
print a
count += 1
else:
for i in xrange(k, len(a)):
a[k], a[i] = a[i], a[k]
perm(a, k + 1)
a[k], a[i] = a[i], a[k]
if n % 2 == 0:
print""
perm(names)
print"total combinations available: " + str(count)
else:
perm(names)
print"total combinations available: " + str(count)
print("please enter an even number next time")
sys.exit()
itertools.combinations()andset().