Why string?


def digit_sum(n):
for digit in sum_list:
return total

so guys im trying to understand this here, why do we have to convert the "n" to a string?
I understand why we have to convert to a list.


We can use an arithmetic algorithm that implements modulo and integer division, or we can use the list method. A number cannot be converted to a list directly, so we convert it to a string, first. A string can be split into a list.

Now that we have a list, we need to evaluate each digit as an integer, after which we perform the addition operation.


You don't have to do anything other than line up a series of instructions for the computer to do produce the correct result. There are several ways to get there.

Why do you think list is needed? Wouldn't a string do the same thing?

And how would an integer get converted to list? An integer doesn't represent a collection of values


Right you are, @ionatan. A list is not really needed, here.


thanks so much, that makes so much sense now!!