Но теперь я не могу открыть этот файл и когда я запускаю свой код, Я получаю ошибку: < /p>
Код: Выделить всё
while True:
user_action = input("Type add, show, edit, complete, or exit: ").strip()
with open('todos.txt', 'r') as file:
todos = file.readlines()
match user_action:
case 'add':
todo = input("Enter a todo: ") + "\n"
todos.append(todo)
case 'show':
for index, item in enumerate(todos):
item = item.title()
print(f"{index + 1}-{item}", end='')
case 'edit':
number = int(input("Number of the todo to edit? ")) - 1
new_todo = input("Enter new todo to replace: ")
todos[number] = new_todo + "\n"
case 'complete':
number = int(input("Number of the todo to complete? ")) - 1
if 0
Подробнее здесь: [url]https://stackoverflow.com/questions/79388070/filenotfounderror-when-trying-to-read-and-write-a-textfile[/url]