List manupulation in functions


n = [3, 5, 7]

Add your function here

def list_extender(lst):
return list_extender(lst)
Oops, try again. list_extender([1, 2, 3, 4]) resulted in an error: maximum recursion depth exceeded.....Help


You called your function in your return statement. Just return lst.

Calling the function in the return statement will make the computer run the function forever and ever (because you didn't tell it when to stop) causing the maximum recursion depth exceeded error.
This concept is known as recursion if you're interested to learn.


When we return a call to the same function, it sets up a recursion and since there is no state change, it will be an infinite loop. Return just the list.


can you tell me the full code... I am still not able to get answer it


You're really close with your code. You just need to change the last line so that you are just returning your list and not returning your function call.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.