Given an integer between 0 and 10000, write a program to print the sum of its digits.Input
The first line of input will contain an integer.Output
The first line of output should be the sum of the digits.Explanation
For example, if the given number is 25, your code should print the sum of the digits (2 + 5), which is 7.
Similarly, if the given number is 692, your code should print the sum of the digits (6 + 9 + 2), which is 17.
Similarly, if the given number is 9999, your code should print the sum of the digits (9 + 9 + 9 + 9), which is 36.
Sample Input 1
25
Sample Output 1
7
Sample Input 2
692
Sample Output 2
17
Sample Input 3
9999
Sample Output 3
36
Python 3.9
RESET
print(sum([int(d) for d in input()]))
Comments
Good
Leave a comment