是否有命令将代码重置为某一行? (蟒蛇)

时间:2018-05-02 17:42:40

标签: python

我已经完成了一个我一直在做的项目,这是一个刽子手游戏。我一直在尝试添加一个功能,您可以在完成后重新启动游戏并选择新的难度。它有效,排序,但无论何时选择已经选择的难度,它都会杀死该程序。我想知道是否有一个命令允许我将程序重置为代码开头某处的某一行。

Full Code Here

问题因素(供参考):

  if lives == 0:
    print("           ")
    print("-Im sorry, " + playername + ", it seems that you cannot make any more mistakes.")
    print("-The answer was '" + letter1 + letter2 + letter3 + letter4 + "'.")
    print("-Better luck next time.")
    print("                           ")
    playagain = str(input("Would you like to play again, " + playername + "? "))
    while True:
        if playagain in (accept, reject):
            break
        print("                           ")
        print("-I'm sorry, " + playername + ", I do not understand your answer . . .")
        print("                           ")
        playagain = str(input("Would you like to play again, " + playername + "? "))
        print("                           ")

    if playagain == accept:
         lives = 6
         from random import randint
         num = randint(1,10)
         true1 = False
         true2 = False
         true3 = False
         true4 = False
         difficulty = str(input("Choose a difficulty, easy, medium or hard. "))
         break

    if playagain == reject:
         print("⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀")
         print("Thank you for playing!")
         print("This game was coded by *developer name*")
         break

1 个答案:

答案 0 :(得分:0)

Python没有goto或等效的命令。