<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sanitize_url(url: str) -> str: """ Sanitize the given url so that it can be used as a valid filename. :param url: url to create filename from :raise ValueError: when the given url can not be sanitized :return: created filename """


    for part in reversed(url.split('/')):
        filename = re.sub(r'[^a-zA-Z0-9_.\-]', '', part)
        if len(filename) > 0:
            break
    else:
        raise ValueError('Could not create reasonable name for file from url %s', url)

    return filename