Это текстовая приключенческая игра. Пользователь сталкивается с первым сценарием a()
. Если они выбирают 2, игра продолжается. Если они выбирают 1, они умирают и им предоставляется возможность снова сыграть. Не уверен, что я здесь делаю не так.
"""
MAIN LOOP
"""
play_again = "yes"
while play_again == "yes" or play_again == "y":
a() # user makes a choice
choice = choose_ans()
check_ans_a(choice) # intention: if user chooses "1", they die and are asked to play again
if choice == "1": # problem: Unexpected indent. If indent is deleted, b() becomes unreachable
play_again = input('Play again?\n'
'(y)es ')
break
else:
continue
b()
choice = choose_ans()
check_ans_b(choice)
РЕДАКТИРОВАТЬ: Решение, полученное из комментариев ниже, было простым:
"""
MAIN LOOP
"""
play_again = "yes"
while play_again == "yes" or play_again == "y":
a() # user makes a choice
choice = choose_ans()
check_ans_a(choice)
if choice == "1" # player dies
play_again = input('Play again?\n'
'(y)es ')
continue # restarts loop
b()
choice = choose_ans()
check_ans_b(choice)