Snake game only works by itself not when i move to other repls

Question:
Why does the same code not work in other repls?
Repl link:
Original link = https://replit.com/@creaternet101/Snake-game
The one I moved the code to = https://replit.com/@creaternet101/Game-Archive/ (fork it to see code)

code snippet

Well, do you know what the code:

if __name__ == "__main__":
    game = Game()
    game.play()

does?
It makes it so that the code is only run if it is in the main “entrypoint” file (which in replit, is usually main.py).
Just remove the if statement, you don’t need that check inside of a function.

1 Like

thanks i was playing around a bit with ai so i didn’t look at it correctly。

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.