human
Rearrange a binary string as alternate x and y occurrences | Function which arrange the given string.
Counting number of 0 ' s ▁ and ▁ 1' s in the given string ..
Printing first all 0 ' s ▁ x - times ▁ ▁ and ▁ decrement ▁ count ▁ of ▁ 0' s x - times and do the similar task with '1  .
Driver code"
How can the above be solved in Python?
 Write me a code to rearrange a binary string as alternate x and y occurrences and the other steps required?
assistant
#Here is code to rearrange a binary string as alternate x and y occurrences and the other steps required.
 def arrangeString ( str1 , x , y ) :
	count_0 = 0
	count_1 = 0
	n = len ( str1 )
	for i in range ( n ) :
		if str1 [ i ] == '0' :
			count_0 += 1
		else :
			count_1 += 1
	while count_0 > 0 or count_1 > 0 :
		for i in range ( 0 , x ) :
			if count_0 > 0 :
				print ( "0" , end = " " )
				count_0 -= 1
		for j in range ( 0 , y ) :
			if count_1 > 0 :
				print ( "1" , end = " " )
				count_1 -= 1
if __name__ == ' _ _ main _ _ ' :
	str1 = "01101101101101101000000"
	x = 1
	y = 2
	arrangeString ( str1 , x , y )