human
Count 1 s in binary matrix having remaining indices of its row and column filled with 0 s | Function to count required 1 s from the given matrix.
Stores the dimensions of the mat.
Calculate sum of rows.
Calculate sum of columns.
Stores required count of 1 s.
If current cell is 1 and sum of row and column is 1.
Increment count of 1 s.
Return the final count.
Driver Code.
Given matrix.
Function call"
How can the above be solved in Python?

Can you provide a code to count 1 s in binary matrix having remaining indices of its row and column filled with 0 s and the other steps required?
assistant
#Here is code to count 1 s in binary matrix having remaining indices of its row and column filled with 0 s and the other steps required.
 def numSpecial ( mat ) :
	m = len ( mat )
	n = len ( mat [ 0 ] )
	rows = [ 0 ] * m
	cols = [ 0 ] * n
	i , j = 0 , 0
	for i in range ( m ) :
		rows [ i ] = 0
		for j in range ( n ) :
			rows [ i ] += mat [ i ] [ j ]
	for i in range ( n ) :
		cols [ i ] = 0
		for j in range ( m ) :
			cols [ i ] += mat [ j ] [ i ]
	cnt = 0
	for i in range ( m ) :
		for j in range ( n ) :
			if ( mat [ i ] [ j ] == 1 and rows [ i ] == 1 and cols [ j ] == 1 ) :
				cnt += 1
	return cnt
if __name__ == ' _ _ main _ _ ' :
	mat = [ [ 1 , 0 , 0 ] , [ 0 , 0 , 1 ] , [ 0 , 0 , 0 ] ]
	print ( numSpecial ( mat ) )