<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def generate_example(config, ext='json'):
 """Generate an example file based on the given Configuration object. Args: config (confpy.core.configuration.Configuration):
 The configuration object on which to base the example. ext (str):
 The file extension to render. Choices: JSON and INI. Returns: str: The text of the example file. """

    template_name = 'example.{0}'.format(ext.lower())
    template = ENV.get_template(template_name)
    return template.render(config=config)