Question: Question 2 . 0 Write a function Sum ( n ) that takes a non - negative integer ( n ) and returns the sum
Question
Write a function Sum that takes a nonnegative integer and returns the sum of its digits digitsum as an integer. If is negative andor noninteger, the
function should return "Invalid Input." Be careful with your string formatting. Minor differences will result in a failed test.
Test your Sum function for in the following cell. Assign the output to Feel free to try it for other inputs.
Hint: Strings are iterable.
Examples:'Invalid Input.Invalid Input.a
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
