#follow paimon on grepper import re # Compile ur word p = re.compile(r'hi') # True print(bool(p.search("abcdefghijkl"))) # False print(bool(p.search("abcdefgihjk")))