Я пытаюсь заставить код возвращать пользователя к предыдущей строке кода на основе введенных им данных. Если они отвечают «нет» или «не совсем» и т. д., когда я спрашиваю их, понимают ли они правила, я хочу, чтобы они вернулись к предыдущим строкам кода и прочитали все заново.
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")
В чем именно ваша проблема?