human
Remove " b " and " ac " from a given string | Utility function to convert string to list.
Utility function to convert list to string.
length of string.
Check if current and next character forms ac.
If current character is b.
if current char is ' c ▁ & & ▁ last ▁ char ▁ in ▁ output ▁ ▁ is ▁ ' a ' so delete both.
Else copy curr char to output string.
Driver program"
How can the above be solved in Python?

Write me a code to remove " b " and " ac " from a given string and the other steps required?
assistant
#Here is code to remove " b " and " ac " from a given string and the other steps required.
 def toList ( string ) :
	l = [ ]
	for x in string :
		l . append ( x )
	return l
def toString ( l ) :
	return ' ' . join ( l )
def stringFilter ( string ) :
	n = len ( string )
	i = - 1
	j = 0
	while j < n :
		if j < n - 1 and string [ j ] == ' a ' and string [ j + 1 ] == ' c ' :
			j += 2
		elif string [ j ] == ' b ' :
			j += 1
		elif i >= 0 and string [ j ] == ' c ' and string [ i ] == ' a ' :
			i -= 1
			j += 1
		else :
			i += 1
			string [ i ] = string [ j ]
			j += 1
	i += 1
	return toString ( string [ : i ] )
string1 = " ad "
print " Input ▁ = > ▁ " + string1 +   "
Output = >   " ,
print stringFilter ( toList ( string1 ) ) +   "
"
string2 = " acbac "
print " Input ▁ = > ▁ " + string2 +   "
Output = >   " ,
print stringFilter ( toList ( string2 ) ) +   "
"
string3 = " aaac "
print " Input ▁ = > ▁ " + string3 +   "
Output = >   " ,
print stringFilter ( toList ( string3 ) ) +   "
"
string4 = " react "
print " Input ▁ = > ▁ " + string4 +   "
Output = >   " ,
print stringFilter ( toList ( string4 ) ) +   "
"
string5 = " aa "
print " Input ▁ = > ▁ " + string5 +   "
Output = >   " ,
print stringFilter ( toList ( string5 ) ) +   "
"
string6 = " ababaac "
print " Input ▁ = > ▁ " + string6 +   "
Output = >   " ,
print stringFilter ( toList ( string6 ) ) +   "
"
string7 = " abc "
print " Input ▁ = > ▁ " + string7 +   "
Output = >   " ,
print stringFilter ( toList ( string7 ) ) +   "
"