human
Permute a string by changing case | Function to generate permutations.
Number of permutations is 2 ^ n.
Converting string to lower case.
Using all subsequences and permuting them.
If j - th bit is set , we convert it to upper case.
Printing current combination.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to permute a string by changing case and the other steps required.
 def permute ( inp ) :
	n = len ( inp )
	mx = 1 << n
	inp = inp . lower ( )
	for i in range ( mx ) :
		combination = [ k for k in inp ]
		for j in range ( n ) :
			if ( ( ( i >> j ) & 1 ) == 1 ) :
				combination [ j ] = inp [ j ] . upper ( )
		temp = " "
		for i in combination :
			temp += i
		print temp ,
permute ( " ABC " )