8. Sum of Digits in a Number

Acceptance — 0 accepted 0 submissions

Easy
No topics listed
No companies listed
Write a Python program that asks the user to enter a number. Then calculate the sum of all individual digits in that number and print the result. For example, if the user enters 123, the sum of digits is 1 + 2 + 3 = 6. The program must take the number as input from the user.

Example 1

Input
123
Output
6

Explanation 1+2+3 = 6

Example 2

Input
456
Output
15

Explanation 4+5+6 = 15

Example 3

Input
0
Output
0

Explanation 0 has only one digit so sum is 0

Acceptance —
Accepted 0
Submissions 0
Auto-save
Saved Ln 1, Col 1
Submit a solution to see its status here.
Input
Expected Output
6
No results yet
Run your code to test it against the sample cases.
Problem List