builder pattern form generator that would generate any form you could imagine by now you should be picking up bad smell stacking loops and conditional statements inside and on top of each other quickly becomes unreadable and unmaintainable let' clean up the code bit we are going to take the meat of each field' generation code and place that into separate function that takes the dictionary and returns snippet of html code that represents that field the key in this step is to clean up the code without changing any of the functionalityinputor output of the main function cleaned_html_dictionary_ form_ generator py def generate_webform(field_dict_list)generated_field_list [for field_dict in field_dict_listif field_dict["type"="text_field"field_html generate_text_field(field_dictelif field_dict["type"="checkbox"field_html generate_checkbox(field_dictgenerated_field_list append(field_htmlgenerated_fields "\njoin(generated_field_listreturn "{fields}format(fields=generated_fieldsdef generate_text_field(text_field_dict)return '{ }:formattext_field_dict["label"]text_field_dict["name"def generate_checkbox(checbox_dict)return { }formatcheckbox_dict["id"]checkbox_dict["value"]checkbox_dict["label"