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

php - Admin SDK -- get information about the group -

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

Python Error - TypeError: input expected at most 1 arguments, got 3 -