Part of the goal of my program is to show all the books in the dictionary and for the user to have the ability to search for a title of a book.
I created a function called retrieve_books where I declared a list called list_of_books. Then I opened the file called "books.csv" to read form the list_of_books. Then I appended the list_of_books with the title, author and year in the dictionary and then returned the list_of_books but I keep getting a "ValueError: Too many values to unpack".
I have tried looking through StackOverflow and have found similar ways to solve the problem but presently, none of them correct the issue. I have tried creating a conditional statement to resolve the issue. I have also tried unpacking one variable at a time. I tried using the keyword Values or Items. If I modify anything different in the in the code it gives me indentation errors.
def retrieve_books():
list_of_books = {}
with open("books.csv", "r") as list_of_books:
for books in list_of_books:
# Extracts the values from the CSV data
title, author, year = list_of_books
# Creates a dictionary from the csv data and adds it to the books list
list_of_books.append({
"title": title,
"author": author,
"year": year
})
return list_of_books
![How to assign multiple variables to a dictionary [closed]](https://file.115kc.com/storage/eg/image305.jpg)