Challenge #1
Lesson 10 of 14 in Coddy's Dictionary in Python course.
Challenge
EasyCreate a function named add_book that adds books to a library catalog represented as a dictionary. The function should take the title (the key), author, and publication year as input parameters and add a new book entry to the catalog with initial availability marked as "available."
Your function signature should look like this:
def add_book(catalog, title, author, year):
# Your code here
catalogis the library catalog dictionary.titleis the title of the book.authoris the author of the book.yearis the publication year of the book.
Your function should add a new book entry to the catalog with the specified details, like this:
add_book(catalog, "The Great Gatsby", "F. Scott Fitzgerald", 1925)
add_book(catalog, "To Kill a Mockingbird", "Harper Lee", 1960)
After running the function with these examples, the catalog dictionary should include these two books with their details and an initial availability status.
Try it yourself
def add_book(catalog, title, author, year):
# Your code here