<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_jinja2_ext(pelican):
 """Add Webassets to Jinja2 extensions in Pelican settings."""


    if 'JINJA_ENVIRONMENT' in pelican.settings: # pelican 3.7+
        pelican.settings['JINJA_ENVIRONMENT']['extensions'].append(AssetsExtension)
    else:
        pelican.settings['JINJA_EXTENSIONS'].append(AssetsExtension)