forked from github/copilot-cli-for-beginners
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
36 lines (27 loc) · 946 Bytes
/
Copy pathutils.py
File metadata and controls
36 lines (27 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def print_menu():
print("\n📚 Book Collection App")
print("1. Add a book")
print("2. List books")
print("3. Mark book as read")
print("4. Remove a book")
print("5. Exit")
def get_user_choice() -> str:
return input("Choose an option (1-5): ").strip()
def get_book_details():
title = input("Enter book title: ").strip()
author = input("Enter author: ").strip()
year_input = input("Enter publication year: ").strip()
try:
year = int(year_input)
except ValueError:
print("Invalid year. Defaulting to 0.")
year = 0
return title, author, year
def print_books(books):
if not books:
print("No books in your collection.")
return
print("\nYour Books:")
for index, book in enumerate(books, start=1):
status = "✅ Read" if book.read else "📖 Unread"
print(f"{index}. {book.title} by {book.author} ({book.year}) - {status}")