i need it to print like how a 'pretty print' would print my outputs. I CANNOT USE the pretty print command. - Using for loops or loops in general is how i need to get the answer

Np Ms Office 365/Excel 2016 I Ntermed
1st Edition
ISBN:9781337508841
Author:Carey
Publisher:Carey
Chapter8: Working With Advanced Functions
Section: Chapter Questions
Problem 2.11CP
icon
Related questions
Question

hey i need help fixing my python code. I have to create a dictionary out of csv file list. 

-  i need it to print like how a 'pretty print' would print my outputs. I CANNOT USE the pretty print command.

- Using for loops or loops in general is how i need to get the answer

-this is how it SHOULD print: (see image attached with white background)

 

 

 

THIS IS MY CODE:

import csv

def book_list(dataset: str) -> dict[str,str]:

   list_of_books = list()

   book_data = csv.reader(open('Google_Books_Dataset.csv','r'))
   
   
   for row in book_data:
       list_of_books.append(row)
       
   header = list_of_books[0]
   dataset = []
   
   for i in list_of_books[1:]:
       dict = {}
       
       for j in range (len(i)):
           header[0] = header[0][3:] 
           dict.update({header[j] : i[j]})     
           dataset.append(dict)
  
   
   return dataset

 

 

--- it SHOULDN'T print like this (see image attached with black background)

= [{"title": "Antiques Roadkill: A Trash 'n' Treasures Mystery",
"authors":
Barbara Allan",
"language ": "English",
"rating": 3.3,
"publisher":
"category": "
"pageCount": 288},
{"title": "The Nightshift Before Christmas: Festive hospital
Kensington Publishing Corp.",
Fiction",
diaries from the author of million-copy hit",
"authors": " Adam Kay",
"language": "English",
"rating": 4.7,
"publisher": "Pan Macmillan",
"category": " Biography ",
"pageCount": 112,
},
{another element},
...
Transcribed Image Text:= [{"title": "Antiques Roadkill: A Trash 'n' Treasures Mystery", "authors": Barbara Allan", "language ": "English", "rating": 3.3, "publisher": "category": " "pageCount": 288}, {"title": "The Nightshift Before Christmas: Festive hospital Kensington Publishing Corp.", Fiction", diaries from the author of million-copy hit", "authors": " Adam Kay", "language": "English", "rating": 4.7, "publisher": "Pan Macmillan", "category": " Biography ", "pageCount": 112, }, {another element}, ...
[{'': '1', 'title': "Antiques Roadkill: A Trash 'n' Treasures Mystery", 'author': 'Barbara Allan',
on', 'language': 'English'}, {'': '31', 'title': 'No Mercy: The brand new novel from the Queen of (
Martin', 'rating': '4.5', 'publisher': 'HarperCollins UK', 'page_count': '864', 'generes': 'Fantas)
'89',
'title': 'The Mysterious Affair at Styles', 'author': 'Agatha Christie', 'rating': '4.4', 'pu
: '5', 'publisher': 'Simon and Schuster', 'page_count': '224', ' generes': 'Economics', 'language':
1', 'author': 'Art Baltazar', 'rating': '4.1', 'publisher': 'DC', 'page_count': '164', 'generes':
'English'}, {'': '176', 'title': 'The Secrets of Saving and Investing with Alvin Hall: Simple Strat
|>>|
Transcribed Image Text:[{'': '1', 'title': "Antiques Roadkill: A Trash 'n' Treasures Mystery", 'author': 'Barbara Allan', on', 'language': 'English'}, {'': '31', 'title': 'No Mercy: The brand new novel from the Queen of ( Martin', 'rating': '4.5', 'publisher': 'HarperCollins UK', 'page_count': '864', 'generes': 'Fantas) '89', 'title': 'The Mysterious Affair at Styles', 'author': 'Agatha Christie', 'rating': '4.4', 'pu : '5', 'publisher': 'Simon and Schuster', 'page_count': '224', ' generes': 'Economics', 'language': 1', 'author': 'Art Baltazar', 'rating': '4.1', 'publisher': 'DC', 'page_count': '164', 'generes': 'English'}, {'': '176', 'title': 'The Secrets of Saving and Investing with Alvin Hall: Simple Strat |>>|
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Basics of loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning