Believe it or not, usually the way to determine if code is correct is to run it in a suitable testbed. It's way too easy to miss something just by reading the code.

So I suggest you create a testbed to exercise this code. So create a new 2d list, add some items, display the list in such a way as you can check that something is wrong, for example if you enter an item at (5,10) and it displays at (10,5) then you've got an x-y transposition bug somewhere.

Cos that's what I would have to do to verify your code, and it doesn't really help much for me to do that; you may as well do it. If you've written the above code then you should have the skills to create a suitable testbed for it.