class Library
class Library
"""
A class to represent a library.
Attributes:
name (str): The name of the library.
books (list): A list of books available in the library.
Methods:
add_book(book): Adds a book to the library's collection.
remove_book(book): Removes a book from the library's collection.
list_books(): Prints a list of all books in the library.
"""
Parameters:
name (str): The name of the library.
"""
self.name = name
self.books = []
Parameters:
book (str): The title of the book to remove.
Raises:
ValueError: If the book is not found in the collection.
"""
if book not in self.books:
raise ValueError(f"'{book}' not found in the library.")
self.books.remove(book)
def list_books(self):
"""Prints a list of all books in the library."""
if not self.books:
print("The library is empty.")
else:
print(f"Books in {self.name}: {', '.join(self.books)}")