I know there has been a question asked on this topic, but none of the answers have helped me. I don\'t need help with implementing the code, I just need help sorting through the
You can use a flag to keep track whether you're in the most outer level of the calls.
def second_smallest(numbers, top_level=True):
# Do your stuff and call `second_smallest(numbers[1:], False)` for any recursions.
# When it comes to returning a value from the function, use the following.
if top_level:
return result[0] # what your function ultimately returns
return result # [second, first] since you're still in recursive calls