I am making a simple script in Python as an exercise that evaluates the Ackermann Function. First the script asks the user for an input, and then attempts to calculate the rest. Here is the code:
m = int(input('Please input m.\n'))
n = int(input('Please input n.\n'))
def compute(m, n):
if m == 0:
print(n + 1)
elif m > 0 and n == 0:
compute(m - 1, 1)
else:
compute(m - 1, compute(m, n - 1))
compute(m, n)
The part that has me confused is when it returns a TypeError, particularly for lines in compute(m, n) where I attempt to add or subtract 1 from n and m.
print(n + 1)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
I understand that Python takes all inputs as string, which is why I specifically converted the input using int() at the very start of the script. And yet, the TypeError seems to implicate that in compute(m, n), m and n are not int, but rather NoneType thus they cannot be added or subtracted. Why is this, and how can I fix this?