The most direct solution is brutally simple:
Python strings have endswith and startswith methods.
you just need a regular expression like this one:
the @ signs are delimiters, saying “the regular expression is everything between these”
we look for the string ‘ism’
and we use $ to say “after ism, this must be the end of the string”
so take your string, s and check it against that regex, return true if it matches and false otherwise