I would like to know how I can output the number of iterations when finding the root using Newtons method. I am calculating the root automatically using Scipy, so I wanted to know if there is a way of knowing how many iterations it took:
from spicy.optimize import newton
from math import *
f = lambda x : x**2 - sin(x)
ans = newton(f, 1, tol = 1.0E-8, maxiter = 100)
print(round(ans, 8))