Problem scenario
Your Python function prints out the value of the variable immediately before it returns the variable. When it is assigned via the "return" statement, the value is "None". You were expecting an integer or some other value. What is wrong?
Solution
Does your function use recursion? If it is using recursion rather than merely calling the function and it returns "None", use the return statement. For example, this would cause the problem:
def coolfunction(x):
....
coolfunction(x)
This rewrite of the above would solve the problem of the unwanted "None" returning from your function:
def coolfunction(x):
....
return coolfunction(x)