human
Segregate 0 s and 1 s in an array | Function to segregate 0 s and 1 s.
Counts the no of zeros in arr.
Loop fills the arr with 0 until count.
Loop fills remaining arr space with 1.
Function to print segregated array.
Driver function"
How can the above be solved in Python?
 Can you provide a code to segregate 0 s and 1 s in an array and the other steps required?
assistant
#Here is code to segregate 0 s and 1 s in an array and the other steps required.
 def segregate0and1 ( arr , n ) :
	count = 0
	for i in range ( 0 , n ) :
		if ( arr [ i ] == 0 ) :
			count = count + 1
	for i in range ( 0 , count ) :
		arr [ i ] = 0
	for i in range ( count , n ) :
		arr [ i ] = 1
def print_arr ( arr , n ) :
	print ( " Array ▁ after ▁ segregation ▁ is ▁ " , end = " " )
	for i in range ( 0 , n ) :
		print ( arr [ i ] , end = " ▁ " )
arr = [ 0 , 1 , 0 , 1 , 1 , 1 ]
n = len ( arr )
segregate0and1 ( arr , n )
print_arr ( arr , n )