← Problem book: Python
Lesson 86 of 96 · 10 XP
Function: digit sum
Theory and problem statement
Machine translation, not yet reviewed by a native speaker.
Write a function digit_sum(n) that returns the sum of the digits of a non-negative number. Read a number and print the sum of its digits.
Example
Input:
123
Output:
6
Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.