human
Generate all permutations of a string that follow given constraints | Simple Python program to print all permutations of a string that follow given constraint.
Check if current permutation is valid.
Recursively generate all permutation.
Driver Code"
How can the above be solved in Python?

=====
Write me a code to generate all permutations of a string that follow given constraints and the other steps required?
assistant
#Here is code to generate all permutations of a string that follow given constraints and the other steps required.
 def permute ( str , l , r ) :
	if ( l == r ) :
		if " AB " not in ' ' . join ( str ) :
			print ( ' ' . join ( str ) , end = " ▁ " )
		return
	for i in range ( l , r + 1 ) :
		str [ l ] , str [ i ] = str [ i ] , str [ l ]
		permute ( str , l + 1 , r )
		str [ l ] , str [ i ] = str [ i ] , str [ l ]
str = " ABC "
permute ( list ( str ) , 0 , len ( str ) - 1 )