Digit_sum A little help here


why isn't that working

def digit_sum(x):
    if len(str(x))>1:
        for char in a:
        return x


from the instructions:

Write a function called digit_sum that takes a positive integer n as input and returns the sum of all that number's digits

if i now want the digit_sum of 434, nothing gets returned.

Also, for validation the function will be called several times (not the whole script) so place nums = [] inside your function


Thanks !:sweat_smile:


issue resolved? If so, well done :slight_smile: i just gave a small hint and you solved it yourself :slight_smile:


It turns out , it was the "print" statement that confused me .

I appreciate your help .