-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForgetfullibrarian.py
More file actions
79 lines (73 loc) · 3.43 KB
/
Copy pathForgetfullibrarian.py
File metadata and controls
79 lines (73 loc) · 3.43 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
book_library = {
"Book 1": ["The Great Gatsby", 113, "Reserved"],
"Book 2": ["To Kill a Mockingbird", 135, "Available"],
"Book 3": ["1984", 142, "Available"],
"Book 4": ["Pride and Prejudice", 124, "Lost"],
"Book 5": ["Think and Grow Rich", 111, "Reserved"],
"Book 6": ["Engineering Mathematics", 156, "Borrowed"],
"Book 7": ["Harry Potter", 117, "Lost"],
"Book 8": ["Anatomy of the Human Body", 132, "Available"],
"Book 9": ["Atomic Habits", 128, "Borrowed"],
}
selected_book = input("Enter Book Name or Book ID: ").strip().lower()
def display_books():
print("Book Library:")
for book, details in book_library.items():
print(f"{book}: Title - {details[0]}, ID - {details[1]}, Status - {details[2]}")
if selected_book in book_library:
book_details = book_library[selected_book]
print(f"Book Details for {selected_book}:")
print(f"Title: {book_details[0]}, ID: {book_details[1]}, Status: {book_details[2]}")
else:
print("Book not found in the library.")
user_actions = input("Choose an action (Add book / borrow book / return book / reserve book / mark book as lost / display the library): ").strip().lower()
if user_actions == "Add book":
new_book_name = input("Enter Book Name (e.g., Book 10): ")
new_title = input("Enter Book Title: ")
new_id = int(input("Enter Book ID: "))
new_status = input("Enter Book Status (Available, Reserved, Borrowed, Lost): ")
book_library[new_book_name] = [new_title, new_id, new_status]
print(f"{new_book_name} has been added to the library.")
elif user_actions == "borrow book":
book_to_borrow = input("Enter the name of the book you want to borrow: ")
if book_to_borrow in book_library:
if book_library[book_to_borrow][2] == "Available":
book_library[book_to_borrow][2] = "Borrowed"
print(f"You have borrowed {book_to_borrow}.")
else:
print(f"Sorry, {book_to_borrow} is not available.")
else:
print("Book not found in the library.")
elif user_actions == "return book":
book_to_return = input("Enter the name of the book you want to return: ")
if book_to_return in book_library:
if book_library[book_to_return][2] == "Borrowed":
book_library[book_to_return][2] = "Available"
print(f"{book_to_return} has been returned.")
else:
print(f"Sorry, {book_to_return} is not borrowed.")
print("Book not found in the library.")
elif user_actions == "reserve book":
book_to_reserve = input("Enter the name of the book you want to reserve: ")
if book_to_reserve in book_library:
if book_library[book_to_reserve][2] == "Available":
book_library[book_to_reserve][2] = "Reserved"
print(f"{book_to_reserve} has been reserved.")
else:
print(f"Sorry, {book_to_reserve} is not available for reservation.")
else:
print("Book not found in the library.")
elif user_actions == "mark book as lost":
lost_book = input("Enter the name of the lost book: ")
if lost_book in book_library:
if not (book_library[lost_book][2] == "Lost"):
book_library[lost_book][2] = "Lost"
print(f"{lost_book} has been marked as lost.")
else:
print(f"{lost_book} is already marked as lost.")
else:
print("Book not found in the library.")
elif user_actions == "display the library":
display_books()
else:
print("Okay, see you next time!")