For the code below:
su = 0
def sod(N):
global su
su += N%10
if N != 0:
N = int(N/10)
sod(N)
return su
print(sod(int(input())))
The result is correct. For example., for input 16 its printing 7.
But for the code below
su = 0
def sod(N):
global su
su += N%10
if N != 0:
N = int(N/10)
sod(N)
else:
return su
print(sod(int(input())))
The result is unexpected. Its printing None.