Objective
Develop a Python program that asks the user for a number and stores it as text. Then, implement a function called sum_digits that receives the text and returns the sum of its digits.
Instructions
- In the
mainfunction, ask the user for a number and keep it as a text. - Implement the function
sum_digitswith the text as a parameter. It adds up the digits and returns the result. - Print the result with a message indicating that it is the sum of the digits of the number.
2222222222222222222222
The sum of the digits is: 44
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise