recursion - python tail recursive function doesn't return -


i have function modifies list, doesn't return anything. long function give example, following has same problem. why not returning anything?

def inventedfunction(list1):     list2=list1[:-1]     if len(list2)!=1:         inventedfunction(list2)      else:         return list2   

replace inventedfunction(list2) return inventedfunction(list2). if call without return statement, result thrown out.

working code:

def inventedfunction(list1):     list2=list1[:-1]     if len(list2)!=1:         return inventedfunction(list2)      else:         return list2  

Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -