Traceback (most recent call last):
File "python", line 14, in
File "python", line 2, in digit_sum
NameError: global name 'n' is not defined
"Write a function called digit_sum that takes a positive integer n as input and returns the sum of all that number's digits."
I think I did some mistakes and some unefficent writing, I really appriciate the help!
def digit_sum(num): str(num) == n len(n) == l Number = 0 while l > 0: for digits in range(l): Number += int(num[l]) l -=1 return Number print digit_sum(666)