Recursive function: In a function, call the function itself. The default maximum depth of recursion 998.
It is how many times to execute, given it ? Plus a counter. The default recursion depth of 998
count = 0 def func1(): global count count += 1 print(count) func1() func1()
Recursion depth is changed
Import SYS sys.setrecursionlimit ( 100000) # change the default recursion depth COUNT = 0 DEF func1 (): , Ltd. Free Join COUNT COUNT + 1 = Print (COUNT) func1 () func1 ()
Of age
def func(n): if n == 1: return 18 else: return func(n-1) +2 print(func(4)) # 24