sequence = [1, 2, 3, 5, 1, 2, 3, 6, 1, 2, 3]
pattern = [1, 2, 3]

def find_item_after_pattern(sequence, pattern):
    n = len(pattern)
for index in range(0, len(sequence) - n):
    if pattern == sequence[index:index + n]:
        yield sequence[index + n]
for item in find_item_after_pattern(sequence, pattern):
    pass
Переписывание вложенных операторов if в более питонической манере