create a function of hours of sunlight (h) vs day of the year (d)

def sunlight_hours(day_of_year):

if day_of_year < 1 or day_of_year > 365:
return "Invalid day of the year."

day_of_the_year = day_of_year - 1 # Adjusting to 0-based index
daylight_hours = [8, 9, 10, 11, 12, 12.5, 12.5, 12, 11, 10, 9, 8] # Example data (can be modified)

return daylight_hours[day_of_the_year % 12]