Python3 program to generate permutations with only one swap allowed .
def findPermutations ( string , index , n ) : NEW_LINE INDENT if index >= n or ( index + 1 ) >= n : NEW_LINE INDENT print ( ' ' . join ( string ) ) NEW_LINE return NEW_LINE DEDENT DEDENT