Krijo një funksion Python për të klasifikuar librat sipas zhanrit.
def classify_books ((libër):
def classify_books(book): if book.genre == "Fiction": return "Fiction" elif book.genre == "Mystery": return "Mystery" elif book.genre == "Science Fiction": return "Science Fiction" elif book.genre == "Romance": return "Romance" elif book.genre == "Fantasy": return "Fantasy" else: return "Other"