human
Can you provide a code to count non and the other steps required given the following:
Count non | Function to reverse a number.
Store the reverse of N.
Return reverse of N.
Function to get the count of non - palindromic numbers having same first and last digit.
Store the required count.
Traverse the array.
Store reverse of arr [ i ].
Check for palindrome.
IF non - palindromic.
Check if first and last digits are equal.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to count non and the other steps required.
 def revNum ( N ) :
	x = 0
	while ( N ) :
		x = x * 10 + N % 10
		N = N // 10
	return x
def ctNonPalin ( arr , N ) :
	Res = 0
	for i in range ( N ) :
		x = revNum ( arr [ i ] )
		if ( x == arr [ i ] ) :
			continue
		else :
			Res += ( arr [ i ] % 10 == N % 10 )
	return Res
if __name__ == ' _ _ main _ _ ' :
	arr = [ 121 , 134 , 2342 , 4514 ]
	N = len ( arr )
	print ( ctNonPalin ( arr , N ) )