I have a function below, that takes a value as an input, and determines a new_value (the new_value will always be less than the original_value). If the difference between the new_value and the original_value is less than a specified tolerance, the new_value is returned. If the tolerance is greater, the function is called again with the new_value as the argument, to calculate a new_new_value. Depending on the original_value entered, sometimes the tolerance condition is never met. How can I make the function stop iterating after a certain number of iterations? I have tried to put in count=0, the count+=0 after the else, but that doesn't work as it returns to zero each time the function is called again. Thanks
def calc_value(original_value):
# equations to calculate new_value
if original_value - new_value < tolerance:
return new_value
else calc_value(new_value)