Honestly, your code is a mess. And also, not your code. There’s at least a few chunks of code in there that seem like they’ve just been copied from other versions of snake.
Go read what I posted in this thread, about writing your own code, and using objects to keep things tidy: Problems with understanding language - #4 by TfGuy44