What happens when openB=closeB==n; which if condition does it go to?

what happens when it prints the list, how is it entering any of the loops after that?

After printing the list, control goes back to the line where the function was called since recursion uses something called a call stack.
You can try to code a much simpler problem like calculating factorial of a number using recursion to get to know how call stack works.
If any doubts feel free to ask :slight_smile: