human
Sum of elements from an array having even parity | Function that returns true if x has even parity.
We basically count set bits https : www . geeksforgeeks . org / count - set - bits - in - an - integer /.
Function to return the sum of the elements from an array which have even parity.
If a [ i ] has even parity.
Driver code"
How can the above be solved in Python?

Give me a code to sum of elements from an array having even parity and the other steps required?
assistant
#Here is code to sum of elements from an array having even parity and the other steps required.
 def checkEvenParity ( x ) :
	parity = 0
	while ( x != 0 ) :
		x = x & ( x - 1 )
		parity += 1
	if ( parity % 2 == 0 ) :
		return True
	else :
		return False
def sumlist ( a , n ) :
	sum = 0
	for i in range ( n ) :
		if ( checkEvenParity ( a [ i ] ) ) :
			sum += a [ i ]
	return sum
if __name__ == ' _ _ main _ _ ' :
	arr = [ 2 , 4 , 3 , 5 , 9 ]
	n = len ( arr )
	print ( sumlist ( arr , n ) )