Reversing Snake

I’m confused;
I have already got the string but it is not accepted on HTB. I don’t see how fixing the comparison loop is going to change the contents of the string/list