Code works in idle but not on codecademy


Practice Makes Perfect Python

When I run my code into the console, it runs perfectly but the editor keeps giving me this error message:
"Oops, try again. Your function fails on digit_sum(434). It returns 22 when it should return 11"

a = []
def digit_sum(n):
     n = str(n)
     total = 0
     for letter in n:
     for number in a:
        total += number
     return total


You don't need first for loop, but if you are using it you need to put your empty list inside function