Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions git/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def load_books(filename='library.json'):
except json.JSONDecodeError:
return []


def save_books(books, filename='library.json'):
"""
Сохранение списка книг в JSON-файл.
Expand Down Expand Up @@ -102,6 +103,7 @@ def main():
title_to_remove = input("Введите название книги, которую хотите удалить: ").strip()

new_books = remove_book(books, title_to_remove)

if len(new_books) < len(books):
books = new_books
save_books(books)
Expand All @@ -119,6 +121,7 @@ def main():
else:
print("Ничего не найдено.")


elif choice == '5':
print("Выход из программы.")
break
Expand Down