A program that takes the input of an integer N and prints the sum of all its even and odd digits separately.
Input format :
Output format :
Sample Input 1:
Sample Output 1:
Solution :
- N = int(input())
- temp = N
- E = 0
- O = 0
- while temp > 0:
- a = temp // 10
- b = temp % 10
- temp = a
- if b % 2 == 0:
- E = E + b
- else:
- O = O + b
- print(str(E) + ' ' + str(O))
Tags:
Solutions