If I have string needle and I want to check if it exists contiguously as a substring in haystack, I can use:
needle
haystack
if needle in
Using an iterator trick:
it = iter(haystack) all(x in it for x in needle)
This is only a concise version of the same idea presented in another answer.