Я пытаюсь передать входную переменную {i1} из одного цикла в другую часть программы.
Как сделать ее доступной в следующем блоке?
Вот мой код:
from pathlib import Path
Path('menu_17').mkdir(exist_ok=True)
my_folder = Path("./menu_17")
menu_file = my_folder / "menu1.txt"
menu_file.write_text('Show_all_task\nAdd_a_task\nMark_the_task_as_completed\nDelete_task\nGo_out')
with open(menu_file, 'r') as file:
lines1 = file.readlines()
for i, line in enumerate(lines1, 1):
print(f"{i}. {line.strip()}")
i1 = print(int(input("Enter_number: ")))
all_task = my_folder / "all_task1.txt"
with open(all_task, 'r') as file:
lines_a = file.readlines()
for b, line in enumerate(lines_a, 1):
print(f"{b}. {line.strip()}")
else:
b < 1 print('EMPTY')
Подробнее здесь: https://stackoverflow.com/questions/797 ... -execution