Why didn't Python stop the code, when 'return' statement appeared?
While I was reading this code:
def factorial(number):
if not isinstance(number, int):
raise TypeError("Sorry. 'number' must be an integer.")
if number < 0:
raise ValueError("Sorry. 'number' must be zero or positive.")
def inner_factorial(number):
if number <= 1:
return 1
return number * inner_factorial(number - 1)
return inner_factorial(number)
I couldn't understand this part of the code:
def inner_factorial(number):
if number <= 1:
return 1
return number * inner_factorial(number - 1)
return inner_factorial(number)
I mean, doesn't Python stop the code, when it sees the statement return
? I want to know how the return number * inner_factorial(number - 1)
code line works.
from Recent Questions - Stack Overflow https://ift.tt/3A1IpxP
https://ift.tt/eA8V8J
Comments
Post a Comment