You need to start with deciding what actions your program should be carrying out.
You're trying to write code before deciding what it should do. That it doesn't work out is not surprising.
So, if you have a list of lists of values, and you want a list with all those values, what actions would have that effect? Write it out in English, if you like you can write them as comments. Keep in mind that each thing you write has to be something you know how to do in code, so if something is complicated then you have to describe it in greater detail. You can keep it in your head as well, or write the code directly. But you do need to consider it, you can't go from purpose to code without considering how to achieve that purpose. No complicated actions are required, you need to do some looping and perhaps use a few variables - so lacking knowledge of the language isn't a show stopper.
You also need to keep track of your variables. At the beginning of your function the only thing you have is the argument that was given to the function, so you will have to manipulate that. You can't for example use the global variable n, because that isn't necessarily the argument to the function, and you wouldn't need to look outside the function for that value anyway because the input is given as an argument.