Python 3.x 当选择了错误的路径时,我希望游戏从头开始,我该怎么做? 启动菜单

Python 3.x 当选择了错误的路径时,我希望游戏从头开始,我该怎么做? 启动菜单,python-3.x,Python 3.x,如果选择下面的“路径2”,我希望程序从此处重新启动 print ("Before you start the game ensure that you are playing in fullscreen to enhance your gaming experience") print("") print ("") time.sleep(1) print ("Menu") print ('Instructions: In this game you will be given a series

如果选择下面的“路径2”,我希望程序从此处重新启动

print ("Before you start the game ensure that you are playing in fullscreen to enhance your gaming experience")
print("")
print ("")
time.sleep(1)
print ("Menu")
print ('Instructions: In this game you will be given a series of paths. Using your best judgment you will choose the best path by using the "1" or "2" number keys, followed by pressing the "enter" button')
print ('If the wrong path is selected, there will be consequences of either death, or a lower final score.')
print ('Death will end the game, and you will be forced to start from the beginning of the level.')
time.sleep(1)
print ('If you will like to restart, press "r"')
print ('If you will like to quit, press "q"')
print ('If you  want to play level 1, press "1"')
print ('If you want to play level 2, press "2"')
print ('you cannot restart or quit at this time')
print ('')
print ('')
如果用户输入“2”,我希望程序重新启动到程序中较早的位置(我在上面特别说明)

print ("Before you start the game ensure that you are playing in fullscreen to enhance your gaming experience")
print("")
print ("")
time.sleep(1)
print ("Menu")
print ('Instructions: In this game you will be given a series of paths. Using your best judgment you will choose the best path by using the "1" or "2" number keys, followed by pressing the "enter" button')
print ('If the wrong path is selected, there will be consequences of either death, or a lower final score.')
print ('Death will end the game, and you will be forced to start from the beginning of the level.')
time.sleep(1)
print ('If you will like to restart, press "r"')
print ('If you will like to quit, press "q"')
print ('If you  want to play level 1, press "1"')
print ('If you want to play level 2, press "2"')
print ('you cannot restart or quit at this time')
print ('')
print ('')
def levelselection():
    level=""
    while level != "1" and level != "2":
        level = input("Please select a level to play: ")
        return level

level = levelselection()
def path1(path):
    path ==""
    while path !="1" and path!="2":
        path = input("Select a path: ")

if level == "1":
    print("Level 1 selected")
    print ("You and your crew are pinned in the remains of a church on the top floor, along with wounded soldiers. Being fired at by German machine guns, matters will soon only get worse as you see German reinforcements on their way. Find a way to escape with your 9 man crew with minimal casualties.")
    time.sleep(1)
    print ("Do you;")
    print ("1:Order your 6 healthy soldiers to provide cover fire while you try and find a way to escape")
    time.sleep(1)
    print ("2:Order 4 soldiers to provide cover fire, while the other two soldiers take care of the wounded and you try and find a way to escape")
    path = input()
    if path == '1':
        print ("The crew provided the cover that was needed to protect you, and you were able to safely make it back with two possible options of escape. The wounded soldiers are starting to bleed out.")
path1(path)
    if path == '2':
        print ("The cover fire did not have enough man power, and you were shot and killed.")