This function is supposed to return the sum of all the digits in a number.
def sum_digits(num):
if int(num) <= 0:
return 0
else:
sum = 0
while int(num) != 0:
n = int(num) % 10
num = int(num) / 10
sum = int(sum + n)
return sum
It works fine for smaller numbers, but if i enter for example number 999999999999999999999999999999999 it returns 74 instead of 297.
Thanks for help