Write a program with loops that compute the sum of all even digits of an input. (For
example, if the input is 32677, the sum would be 2 + 6 = 8.)
Sample Run
Enter integer: 32677
Sum of all even digits = 8
num = input('Enter integer: ')
s = 0
for digit in num:
d = int(digit)
if d % 2 == 0:
s += d
print(f'Sum of all even digits = {s}')
Comments
Leave a comment