have two if functions one with applying text.lower(), and one without. For the original text, have it to return true if matchcase is true or false. But for the lowercase applied, to return true if match case is false and vice versa. Don't forget to return false on the outside if it doesn't match any of the criteria.