input: Write a python function to convert a list of dictionaries into a CSV string format.
  assert convert_to_csv([{'Name': 'John', 'Age': 24, 'Gender': 'Male', 'Hobby': 'Football'}]) == 'Name,Age,Gender,Hobby\nJohn,24,Male,Football\n'
  assert convert_to_csv([{'Name': 'Jane', 'Age': 28, 'Gender': 'Female', 'Hobby': 'Basketball'}]) == 'Name,Age,Gender,Hobby\nJane,28,Female,Basketball\n'
  assert convert_to_csv([{'Name': 'John', 'Age': 24, 'Gender': 'Male', 'Hobby': 'Football'}, {'Name': 'Jane', 'Age': 28, 'Gender': 'Female', 'Hobby': 'Basketball'}]) == 'Name,Age,Gender,Hobby\nJohn,24,Male,Football\nJane,28,Female,Basketball\n'
output: def convert_to_csv(dict_list):
      if not dict_list:
          return ''
      
      headers = dict_list[0].keys()
      csv_data = [",".join(headers)]
      
      for d in dict_list:
          csv_data.append(",".join(str(d[h]) for h in headers))
          
      return "\n".join(csv_data) + "\n"