extensionsToCheck = ('.pdf', '.doc', '.xls') 'test.doc'.endswith(extensionsToCheck) # returns True 'test.jpg'.endswith(extensionsToCheck) # returns False