human
Remove all zero | Function to remove the rows or columns from the matrix which contains all 0 s elements.
Stores count of rows.
col [ i ] : Stores count of 0 s in current column.
row [ i ] : Stores count of 0 s in current row.
Traverse the matrix.
Stores count of 0 s in current row.
Update col [ j ].
Update count.
Update row [ i ].
Traverse the matrix.
If all elements of current row is 0.
If all elements of current column is 0.
Driver Code.
Function Call"
How can the above be solved in Python?
 ... Give me a code to remove all zero and the other steps required?
assistant
#Here is code to remove all zero and the other steps required.
 def removeZeroRowCol ( arr ) :
	n = len ( arr )
	col = [ 0 ] * ( n + 1 )
	row = [ 0 ] * ( n + 1 )
	for i in range ( n ) :
		count = 0
		for j in range ( n ) :
			col [ j ] += ( arr [ i ] [ j ] == 1 )
			count += ( arr [ i ] [ j ] == 1 )
		row [ i ] = count
	for i in range ( n ) :
		if ( row [ i ] == 0 ) :
			continue
		for j in range ( n ) :
			if ( col [ j ] != 0 ) :
				print ( arr [ i ] [ j ] , end = " " )
		print ( )
arr = [ [ 1 , 1 , 0 , 1 ] , [ 0 , 0 , 0 , 0 ] , [ 1 , 1 , 0 , 1 ] , [ 0 , 1 , 0 , 1 ] ]
removeZeroRowCol ( arr )