Suppose we have a number n. We have to check whether the product of odd placed digits and the even placed digits are same or not.
So, if the input is like n = 2364, then the output will be True as product of odd placed numbers are 2 * 6 = 12 and product of even placed numbers are 3 * 4 = 12 which are same.
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
def solve(num): if num < 10: return False odd_place = 1 even_place = 1 while num > 0: d = num % 10 odd_place *= d num = num//10 if num == 0: break d = num % 10 even_place *= d num = num//10 if odd_place == even_place: return True return False num = 2364 print(solve(num))