Digit Sum!


Can anyone tell me where i did wrong ?
I did define digit_sum in the first line.

Here's the error msg:
"Oops, try again. Did you create a function called digit_sum? Your code threw a "local variable 'l' referenced before assignment" error.>"

def digit_sum(n):
    digit = 0
    lis = []
    while n!= 0:
        digit = n % 10
        n = n // 10
        print lis    
    for i in lis:
        l += i
    return l


sounds like a fair error message, here:

l += i

you add something to l, but l isn't anything yet, how can you add to something which doesn't exist?


Thanks to @stetime94,
I solved my problem by defining that variable.