Code works in idle but not on codecademy


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
#Practice Makes Perfect Python

<In what way does your code behave incorrectly? Include ALL error messages.>

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”
<What do you expect to happen instead?>

```python

a =
def digit_sum(n):
n = str(n)
total = 0
for letter in n:
a.append(int(letter))
for number in a:
total += number
return total

<do not remove the three backticks above>

#2

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