I didn't know how to solve this problem, so searched, and this is the one I'm trying to understand.

I thought it would be nice to share. There are one way we can do based on what we learned at the codecademy, but another using 'map.'

link: http://stackoverflow.com/questions/16266130/how-to-get-digit-sum-in-python

You have to change it to a string first :

```
In [24]: num = 123456
In [25]: sum(int(x) for x in str(num))
Out[25]: 21
```

Without converting to a string:

```
def solve(n):
summ=0
while n:
summ+= n%10
n/=10
return summ
....:
In [38]: solve(123456)
Out[38]: 21
```

```
In [1]: num=123456
In [2]: sum(map(int,str(num)))
Out[2]: 21
In [3]: def digitsum(x):
...: return sum(map(int,str(x)))
...:
In [4]: digitsum(num)
Out[4]: 21
```