![]() |
why this error occured in recursion - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: why this error occured in recursion (/thread-26221.html) |
why this error occured in recursion - ashishraikwar - Apr-24-2020 def fact(n): if n<= 1: print(1) #if i use "return 1" here then no error but when i use here print(1) why the error occurred else: return n*fact(n-1) f=fact(3) print(f)
RE: why this error occured in recursion - buran - Apr-24-2020 because when n < 1 your function will not return anything explicitly, so it returns None and thus the error.Check this visualization tool |