I made a CSV file that contains a book, its author, and the year it released. My problem is that when the data is displayed in the file its displayed every other line.
How can I make it where there aren't gaps between the data entries
my code:
import csv
amount = int(input("How many records would you like to add: "))
count = 0
with open("Books.csv", "w", newline="") as file:
writer = csv.writer(file)
writer.writerow(["", "Book", "Author", "Year released"])
while count < amount:
book = input("Enter a book: ")
author = input("Enter it's Author: ")
year = input("Enter the year it released: ")
headers = [count, book, author, year]
with open("Books.csv", 'a') as f:
writer = csv.writer(f)
writer.writerow(headers)
count += 1