我几乎完成了我一直在做的一个项目,这是一个刽子手游戏。我一直在尝试添加一个功能,您可以在完成后重新启动游戏,并选择一个新的难度。这是可行的,但只要你选择了一个已经被选择的难度,它就会终止程序。我想知道是否有一个命令允许我将程序重置到代码开头的某一行
问题区域B(供参考):
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
Python没有
goto
或等效命令相关问题 更多 >
编程相关推荐