I've defined a function that takes as an input a positive integer and returns the sum of its digits:
def digitSum(n):
    exp = 0
    digitSum = 0
    while n%(10**exp) != n:
        digitSum += (n%(10**(exp+1))-n%(10**(exp)))/(10**exp)
        exp += 1
    return digitSum
It seems that if n < 10**9, then digitSum returns an int and returns a long otherwise. If I want it to always return an int, I could have it return int(digitSum) rather than digitSum, so that is not the issue. My question is why does this return a long in the first place?