I need to generate every possible pairs in a list. For example
list=['1','2','3']
The end result that I want to have is
new_list=['1-2','1-3','2-1','2-3','3-1','3-2']
In my case, 1-2 != 2-1. Currently my code is
for x1 in b:
for x2 in b:
if(x1==x2):
continue
else:
x3=x1+'-'+x2
new_list.append(x2)
As my actual data contains hundreds of list, is there any way to not use a double for loop?