Python 将用户返回到前一行

Python 将用户返回到前一行,python,Python,我试图让代码根据用户提供的输入将用户返回到前一行代码。如果他们回答“不”或“不是真的”,等等。当我问他们是否理解规则时,我希望他们返回到前面的代码行并再次阅读 print("Ok, the rules of this 'game' are very simple; You are kind of doing a virtual house tour.") print("You will be inspecting the house for its conditio

我试图让代码根据用户提供的输入将用户返回到前一行代码。如果他们回答“不”或“不是真的”,等等。当我问他们是否理解规则时,我希望他们返回到前面的代码行并再次阅读

print("Ok, the rules of this 'game' are very simple; You are kind of doing a virtual house tour.")
print("You will be inspecting the house for its condition and to see if it is 'sellable'.")
print("You will be going from room to room and checking it out based on the room description I give.")
print("You will be giving each room a number value of 0,1,2, or 3.  A 0 takes away from the value of the house.")
print("A 1 doesn't change the value of the house.  A 2 or a 3 increase the value of the house.")
print("If at any point in the tour you think the house is not 'sellable', you just have to say so and the game ends.")
print("Your progress in the house will be tracked at all times.")
ans2=input("Understand? Are you ready?")
if ans2.lower() in Accept_ans:
    print ("Ok, great!  Lets begin the tour.")
else:
    print("ok, read the instructions again")

如果答案不符合预期,则使用
while
循环返回起点

ok = 0
while not ok:
    print("Ok, the rules of this 'game' are very simple; You are kind of doing a virtual house tour.")
    print("You will be inspecting the house for its condition and to see if it is 'sellable'.")
    print("You will be going from room to room and checking it out based on the room description I give.")
    print("You will be giving each room a number value of 0,1,2, or 3.  A 0 takes away from the value of the house.")
    print("A 1 doesn't change the value of the house.  A 2 or a 3 increase the value of the house.")
    print("If at any point in the tour you think the house is not 'sellable', you just have to say so and the game ends.")
    print("Your progress in the house will be tracked at all times.")
    ans2=input("Understand? Are you ready?")
    if ans2.lower() in Accept_ans:
        print ("Ok, great!  Lets begin the tour.")
        ok = 1
    else:
        print("ok, read the instructions again")

如果答案不符合预期,则使用
while
循环返回起点

ok = 0
while not ok:
    print("Ok, the rules of this 'game' are very simple; You are kind of doing a virtual house tour.")
    print("You will be inspecting the house for its condition and to see if it is 'sellable'.")
    print("You will be going from room to room and checking it out based on the room description I give.")
    print("You will be giving each room a number value of 0,1,2, or 3.  A 0 takes away from the value of the house.")
    print("A 1 doesn't change the value of the house.  A 2 or a 3 increase the value of the house.")
    print("If at any point in the tour you think the house is not 'sellable', you just have to say so and the game ends.")
    print("Your progress in the house will be tracked at all times.")
    ans2=input("Understand? Are you ready?")
    if ans2.lower() in Accept_ans:
        print ("Ok, great!  Lets begin the tour.")
        ok = 1
    else:
        print("ok, read the instructions again")

你的问题到底是什么?已经解决了。如果他们回答“否”或其他问题,我试图让脚本返回到说明中。如果问题已解决,请添加您的解决方案作为自我回答好吗?刚刚完成,现在发布。您的问题到底是什么?已经解决了。如果他们回答“否”或其他问题,我试图让脚本返回到说明中。如果问题已解决,请添加您的解决方案作为自我回答,好吗?刚刚完成,现在发布