def square(inp): return inp*inp def func(name,times): def iters(base): res = base for i in range(times): res = name(res) return res return iters print(func(square,3)(2))