calling a function inside a function inside a function and so on... for n times in python -


i working on mandelbrot set in python. want make function calls function inside function(and on) n times. like,

1st loop: f(x)

2nd loop: f(f(x))

3rd loop: f(f(f(x)))

and on...

now made code.

def f(x):     return x**2  def g(x,n):      if n == 0:         return f(x)     else:         f(g(x,n-1))  g(2,5) 

now i'm expecting result f(f(f(f(f(2))))). , has error,"pow: 'nonetype' , 'int'".

how can fix it? , proper method of doing it?

for in range(n):     x = f(x) print x 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -