Question: use python to write a function read_books(file_name) which takes in the name of a file as parameter and returns a list. Each list item will

use python to write a function read_books(file_name) which takes in the name of a file as parameter and returns a list. Each list item will itself be a list of two items: title and author. Note: The index of the book in this list is the book's index within the user's ratings.

The function should return None if the file could not be read. Otherwise, it should return a list filled with data from that file. Note: if the file is empty, you should return an empty list.

use python to write a function read_books(file_name) which takes in the name

books.txt

The data file containing the books contains a single book per line. Each entry has the authors name and title of the book separated by commas.

Douglas Adams,The Hitchhiker's Guide To The Galaxy Richard Adams,Watership Down Mitch Albom,The Five People You Meet in Heaven Laurie Halse Anderson,Speak Maya Angelou,I Know Why the Caged Bird Sings Jay Asher,Thirteen Reasons Why

I ["The Hitchhiker's Guide To The Galaxy", "Douglas Adams" ["Watership Down", "Richard Adams"], ["The Five People You Meet in Heaven", "Mitch Albom"], "Speak", "Laurie Halse Anderson"]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!