human
Replace all occurrences of string AB with C without using extra space | Python 3 program to replace all occurrences of " AB " with " C ".
Start traversing from second character.
If previous character is ' A ' and current character is 'B".
Replace previous character with ' C ' and move all subsequent characters one position back.
Driver code"
How can the above be solved in Python?

Give me a code to replace all occurrences of string AB with C without using extra space and the other steps required?
assistant
#Here is code to replace all occurrences of string AB with C without using extra space and the other steps required.
 def translate ( st ) :
	for i in range ( 1 , len ( st ) ) :
		if ( st [ i - 1 ] == ' A ' and st [ i ] == ' B ' ) :
			st [ i - 1 ] = ' C '
			for j in range ( i , len ( st ) - 1 ) :
				st [ j ] = st [ j + 1 ]
			st [ len ( st ) - 1 ] = ' ▁ '
	return
st = list ( " helloABworldABGfG " )
translate ( st )
print ( " The ▁ modified ▁ string ▁ is ▁ : " )
print ( ' ' . join ( st ) )