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
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)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps