Given a long integer, we need to find if the difference between sum of odd digits and sum of even digits is 0 or not. The indexes start from zero (0 index is for leftmost digit).

**Examples:**

Input :1212112Output :YesExplanation:-the odd position element is 2+2+1=5 the even position element is 1+1+1+2=5 the difference is 5-5=0.so print yes.Input :12345Output :No Explanation:- the odd position element is 1+3+5=9 the even position element is 2+4=6 the difference is 9-6=3 not equal to zero. So print no.

**Method 1: ** One by one traverse digits and find the two sums. If difference between two sums is 0, print yes, else no.

**Method 2 :** This can be easily solved using divisibility of 11. This condition is only satisfied if the number is divisible by 11. So check the number is divisible by 11 or not.

`# Python program to check if difference between sum of ` `# odd digits and sum of even digits is 0 or not ` ` ` `def` `isDiff(n): ` ` ` `return` `(n ` `%` `11` `=` `=` `0` `) ` ` ` `# Driver code ` `n ` `=` `1243` `; ` `if` `(isDiff(n)): ` ` ` `print` `(` `"Yes"` `) ` `else` `: ` ` ` `print` `(` `"No"` `) ` ` ` `# Mohit Gupta_OMG <0_o> ` |

*chevron_right*

*filter_none*

**Output:**

Yes

Please refer complete article on Difference between sums of odd and even digits for more details!

## Recommended Posts:

- Python program to find the sum of all even and odd digits of an integer list
- Python program to count Even and Odd numbers in a List
- Python Program to Print Largest Even and Largest Odd Number in a List
- Python Program to find Sum of Negative, Positive Even and Positive Odd numbers in a List
- Python Program to create an OTP by squaring and concatenating the odd digits of a number
- Python Program for Odd-Even Sort / Brick Sort
- Python Program for Check if count of divisors is even or odd
- Python Program to Determine Whether a Given Number is Even or Odd Recursively
- Python | Separate odd and even index elements
- Python | N consecutive Odd or Even Numbers
- Python - Odd or Even elements combinations Summations in Matrix
- Python | Even Front digits Test in List
- Sort even and odd placed elements in increasing order
- Binary string with given frequencies of sums of consecutive pairs of characters
- Python program to calculate the number of digits and letters in a string
- Python | Check possible bijection between sequence of characters and digits
- Python Program for Number of elements with odd factors in given range
- Python Program for Find sum of odd factors of a number
- Python program to copy odd lines of one file to other
- Python program to print all odd numbers in a range