Challenge 2: Sum of Digits in a String

Given a string containing numbers, calculate the sum of those numbers.

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!

Press + to interact
def sumDigits(testVariable):
# Write your code here
return None

In the next lesson, we have the solution review of this problem.