def find_all(needle, haystack, npos=0, hpos=0):
    if npos >= len(needle):
        return True
try:
    return find_all(needle, haystack, npos + 1, haystack.index(needle[npos],
        hpos) + 1)
except ValueError:
    return False
print(find_all([1, 3, 5], [1, 2, 3, 4, 5, 6, 7]))
print(find_all([1, 5, 3], [1, 2, 3, 4, 5, 6, 7]))
Comparing element order in Python lists