Challenge 2: Sum of Digits in a String
Given a string containing numbers, calculate the sum of those numbers.
We'll cover the following
Problem Statement
Implement a function that takes a variable testVariable
containing a string of digits and prints all the sum of those digits.
Input
A variable testVariable
containing a string of digits.
Output
Sum of the digits in the string
Sample Input
"345"
Sample Output
12
Try it Yourself
Try to attempt this challenge by yourself before moving on to the solution. Good luck!
def sumDigits(testVariable):# Write your code herereturn None
In the next lesson, we have the solution review of this problem.