Answer to Question #185504 in Python for Woyengimiesindo Malati

Question #185504

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


1
Expert's answer
2021-04-29T07:39:38-0400
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}')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS