I'll go through second approach as it does not include
list and sum() (less code,clean code)..
This code have many bugs : bad indentation,iteration over int type(which is not allowed) etc
c = 0
for x in n:
c += n
I'll give you an example...
suppose there is a number..
x = 1234
now I have to print each digit of this number..
how we go about this problem?
for dig in str(x):
It will print..
By converting number into string,we can iterate over it(as we know we can iterate over string)!
do reply if you get this concept or not!