4. Digit_Sum: Not sure what is wrong



I used Textwrangler on my mac to complete this program step by step and it worked. I then copy pasted my code into the codecademy python interpreter, but I get an error message saying "Your function fails on digit_sum(434)" even though the program produces the correct sum! When I run the code on TextWrangler, no error messages pop up.

I am not sure what I'm doing wrong or if this is just a bug. Any help would be appreciated.

def digit_sum(n):

    #convert n into a string
    n = str(abs(n))
    result = []
    new = []
    #add the characters of the string into an empty list, result
    for letter in n:
    #convert the items in result into integers
    for digit in result:
    	digit = int(digit)
        print digit,
    print result
    print new
    print sum(new)


It's telling you that when you call 434 on the function digit_sum(), it doesn't give the right output, say 11.

Check your loop.