'''
Learning outcomes:
1. Tuples are immutable, meaning once created, their contents cannot be changed.
2. They are ordered, so the elements are indexed and accessed by their positions.
3. The elements can be of any data type. If the data type of the element is mutable, it can be changed at any point in time within the tuple collection. But, the tuple's shape (the order of the elements, adding or removing) cannot be changed
'''
# Tuple of library
# with list of books
books = []
library = (books,)
print("Library: ", library, type(library), type(library[0]))
library[0].append(["The Catcher in the Rye", 1951, "J.D. Salinger", "Fiction"])
print("Library before: ", library)
library[0].extend([["The Hobbit", 1937, "J.R.R. Tolkien", "Fantasy"],
["Pride and Prejudice", 1813, "Jane Austen", "Romance"],
["The Hitchhiker's Guide to the Galaxy", 1979, "Douglas Adams", "Science Fiction"],
["The Da Vinci Code", 2003, "Dan Brown", "Mystery"],
["The Lord of the Rings", 1954, "J.R.R. Tolkien", "Fantasy"]])
print("Library updated: ", library, len(library[0]), end='\n\n')
# update the publication year of the book
# in the middle of the books list
# in library tuple
middle_index = len(library[0])//2 - 1
print("library before change: ", library[0][middle_index])
library[0][middle_index][1] = 1981
print("library after change: ", library[0][middle_index])
print("The element was: ", library[0][1])
publication_year = library[0][1].pop(1)
print("The element is: ", library[0][1])
print('publication_year was: ', publication_year, end='\n\n')
library[0][1] = 1991
print("Library after pop: ", library[0], library[0][2], end='\n\n')