<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def api(root_url, service, version, path):
 """Generate URL for path in a Taskcluster service."""

    root_url = root_url.rstrip('/')
    path = path.lstrip('/')
    if root_url == OLD_ROOT_URL:
        return 'https://{}.taskcluster.net/{}/{}'.format(service, version, path)
    else:
        return '{}/api/{}/{}/{}'.format(root_url, service, version, path)