Thank you for coming back to me.
I tried what you said, but absolutely nothing happened.
Please could you double check
Also should train name not be changed to AA_area?
def main():
... import arcpy
... import os
... arcpy.env.overwriteOutput = True
...
... # settings: edit these
... fc_in = r'C:\Users\Danuta\Desktop\CSS 2016-17\TEST\Agri\Agri_EC_working_data.shp'
... fld_trail = 'AA_area'
... out_folder = r'C:\Users\Danuta\Desktop\CSS 2016-17\TEST'
...
... # create list of unique trail names
... lst_trails = list(set([r[0] for r in arcpy.da.SearchCursor(fc_in, (fld_trail))]))
...
... # loop through trails
... for AA_area in lst_trails:
... fld = arcpy.AddFieldDelimiters(fc_in, fld_trail)
... where ="\"{0}\" = '{1}'".format(fld, trail_name)
... arcpy.MakeFeatureLayer_management(fc_in, "lyr", where)
... kmz_file = os.path.join(out_folder, "{0}.kmz".format(trail_name))
... arcpy.LayerToKML_conversion("lyr", kmz_file)