I am unable to understand as to why the below code does not return the value of 'out' despite it containing values (as evident by uncommenting the print statement)
# Goal is to reverse a list using recurcive functions.
# Ex: [1,'yes', 8, 'pipe', 102] - > [102, 'pipe', 8, 'yes', 1]
inp = [1,'yes', 8, 'pipe', 102]
out = []
def recFn(ctr, out):
if ctr == len(inp)-1:
return out
else:
out = [inp[ctr]] + out
# print(out)
recFn(ctr+1, out)
recFn(0, out)
I get NO output. Can someone tell me why this is the case?