Here is a python function I wrote to generate alphanumeric string and it prints the results correctly however it is not returning any values.
- what am I missing?
import random
import string
def randalphn(nchar :int, nnums:int,result:str) -> str:
if nchar == 0:
if nnums == 0:
print(result)
return result
else:
randalphn(nchar,(nnums - 1), result+str(random.randrange(9)))
else:
randalphn(nchar-1, nnums, result+random.choice(string.ascii_uppercase))
#calling the function prints the result correctly however it does not return any value :(
randalphn(2,4,'')