from urllib.parse import urlparse
import os
path = urlparse(url_string).path
ext = os.path.splitext(path)[1]
if ext in extensionsToCheck:
    pass
How to check if a string contains an element from a list in Python