如何让游戏重启(python龟蛇游戏)

How to make the game restart (python turtle snake game)

所以我想让游戏在玩家撞到墙或自己(输掉游戏)后重新开始我尝试使用 tkinter 但现在不知道该怎么做我只是很困惑。 我还想问一下,有没有办法询问玩家在输掉比赛后是否想再次玩游戏或类似的功能。 我可以将按钮与 turtle 一起使用吗?

方法如下:

import turtle

while True:
    # Your game code
    again = input("Do you want to play again? ")
    if again == 'yes':
        screen.clear()
    else:
        print('Bye!')
        break
    # If the player enters `yes`, the screen will be cleared, then the program will loop back to the top of this while loop