Check if product of digits of a number at even and odd places is equal | Python3 implementation of the approach ; To store the respective product ; Converting integer to string ; Traversing the string ; Driver code
def getResult ( n ) : NEW_LINE INDENT proOdd = 1 NEW_LINE proEven = 1 NEW_LINE num = str ( n ) NEW_LINE for i in range ( len ( num ) ) : NEW_LINE INDENT if ( i % 2 == 0 ) : NEW_LINE INDENT proOdd = proOdd * int ( num [ i ] ) NEW_LINE DEDENT else : NEW_LINE INDENT proEven = proEven * int ( num [ i ] ) NEW_LINE DEDENT DEDENT if ( proOdd == proEven ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT n = 4324 NEW_LINE getResult ( n ) NEW_LINE DEDENT