我的功能几乎是正确的,但是某处存在错误。
你能帮我修一下吗?
def fixedPoint(f, epsilon):
"""
f: that's a function which will return a float
epsilon: it's a float(a small one)
returns the best guess when that guess is less than epsilon
away from f(guess) or after 100 trials, whichever comes first.
"""
guess = 1.0
for i in range(100):
if f(guess) - guess < epsilon:
return guess
else:
guess = f(guess)
return guess