human
Distinct permutations of the string | Set 2 | Returns true if str [ curr ] does not matches with any of the characters after str [ start ].
Prints all distinct permutations in str [ 0. . n - 1 ].
Proceed further for str [ i ] only if it doesn 't match with any of  the characters after str[index].
Driver code"
How can the above be solved in Python?

Can you provide a code to distinct permutations of the string and the other steps required?
assistant
#Here is code to distinct permutations of the string and the other steps required.
 def shouldSwap ( string , start , curr ) :
	for i in range ( start , curr ) :
		if string [ i ] == string [ curr ] :
			return 0
	return 1
def findPermutations ( string , index , n ) :
	if index >= n :
		print ( ' ' . join ( string ) )
		return
	for i in range ( index , n ) :
		check = shouldSwap ( string , index , i )
		if check :
			string [ index ] , string [ i ] = string [ i ] , string [ index ]
			findPermutations ( string , index + 1 , n )
			string [ index ] , string [ i ] = string [ i ] , string [ index ]
if __name__ == " _ _ main _ _ " :
	string = list ( " ABCA " )
	n = len ( string )
	findPermutations ( string , 0 , n )