Hi, I need help with my code.

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. For example: digit_sum(1234) should return 10 which is 1 + 2 + 3 + 4. (Assume that the number you are given will always be positive.)

My code:

def digit_sum(n):

if n % 2 == 0:

total = 0

for i in (n):

total = total + n(i)

return total

digit_sum(432432)

I understand the concept of indexing, I just to make sure if my code is correct.

V/R