Great job! Two more parameters worth noting are
with open('books.csv', mode='w', newline='') as csv_file:
csv_writer = csv.writer(csv_file, fieldnames=['Author', 'Title', 'Pages'], quotechar="'", quoting=csv.QUOTE_ALL)
for row in data_to_save:
quotechar denotes the character that will be used to quote the text we're writing to the CSV.
quoting, on the other hand, allows us to specify when the
csv.DictWriter should use
quoting. Possible options are:
csv.QUOTE_ALL – each field will be enclosed in quote characters.
csv.QUOTE_NONNUMERIC – each field that is not a number (such as int or float) will be quoted.
csv.QUOTE_MINIMAL – quoting will be used only where necessary (i.e., when the field contains the separator character).
csv.QUOTE_NONE – no quoting will take place; a given string will be written as is.