Pregunta

def fdPt(f, eps):
    index = 5.0
    for i in range(57):
        if f(index) - index < eps:
            return guess
        else:
            index = f(index)
    return index

plse help i've tried all i can, am just a beginner

No hay solución correcta

Otros consejos

Without seeing an example of what f is before it is passed into your function, it seems like you might be treating it like a sequence object, and trying to index into it:

if f(index) - index < eps:

... might want to be:

if f[index] - index < eps:

This assumes f is a list, tuple, string, or some other indexable object.

The way you are treating it right now wants to use f like a callable (function, method, class constructor, ...)

To help with checking your objects, try printing the type of f:

def fdPt(f, eps):
    print f, type(f)
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top