Quick Python Script for CSV. Lunar Date Converter

Question:
I got this code from CHATGPT4. I need a complete list of lunar dates and their matching gregorian dates 50 years back and 20 years forward. Can you use this code or other code to make me a csv file?
Repl link:

import ephem
import csv
from datetime import datetime

# Create a list to store the dates
dates = []

# Loop over the years
for year in range(datetime.now().year - 50, datetime.now().year + 1):
    # Loop over the months
    for month in range(1, 13):
        # Loop over the days
        for day in range(1, 32):
            try:
                # Create a date string
                date_str = f"{year}/{month}/{day}"
                # Convert to a lunar date
                lunar_date = ephem.previous_new_moon(date_str)
                # Add to the list of dates
                dates.append([date_str, str(lunar_date)])
            except:
                pass

# Write the dates to a CSV file
with open("lunar_dates.csv", "w", newline="") as f:
    writer = csv.writer(f)
    writer.writerows(dates)