def build_template(data):
    """
    Build and return an addressbook file template
    """
    template = (
        '# abook addressbook file\n\n[format]\nprogram=abook\nversion=0.6.1\n\n'
        )
    for index, entry in enumerate(data):
        template += (
            f"\n[{index}]\nname={entry['name']}\nemail={','.join(entry['email'])}\n"
            )
        if entry['notes']:
            template += f"notes={entry['notes']}\n"
        if entry['custom1']:
            template += f"custom1={entry['custom1']}\n"
    template += '\n'
    return template
