I'm writing a password generator, one that takes a string (the URL of a website) and processes it into a secure password that can't be backtracked based on the name of the website.
In part of the code, I created a recursive function that looks like this:
def get_number(n = 0, nums = ''):
for i in range(0, len(url)):
#both n and nums are changed
if len(nums) < num_length:
get_number(n, nums)
else:
print(nums)
return(nums)
...
print(get_number())
I would expect nums
to output twice, since I print it in the else block and print the return later on. But, if it does go through a recursive loop, nums
is printed from the else block and the function returns None
. If if len(nums) < num_length
is false the first time, then it returns the proper value.
Why would it return None
, if I verified that the object it is returning is not in fact None
the line before?
I'm a little new to Python; does it handle recursions differently?