human
Check if sum of exactly K elements of the Array can be odd or not | Function returns true if it is possible to have odd sum.
Counting number of odd and even elements.
Driver code"
How can the above be solved in Python?
 Can you provide a code to check if sum of exactly K elements of the Array can be odd or not and the other steps required?
assistant
#Here is code to check if sum of exactly K elements of the Array can be odd or not and the other steps required.
 def isPossible ( arr , N , K ) :
	oddCount = 0
	evenCount = 0
	for i in range ( N ) :
		if ( arr [ i ] % 2 == 0 ) :
			evenCount += 1
		else :
			oddCount += 1
	if ( evenCount == N or ( oddCount == N and K % 2 == 0 ) or ( K == N and oddCount % 2 == 0 ) ) :
		return False
	else :
		return True
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 2 , 3 , 4 , 5 , 8 ]
	K = 5
	N = len ( arr )
	if ( isPossible ( arr , N , K ) ) :
		print ( " Possible " )
	else :
		print ( " Not ▁ Possible " )