import re s = 'ACAABAACAAABACDBADDDFSDDDFFSSSASDAFAAACBAAAFASD' pattern = r'[B-Z](?=AAA)' for item in re.finditer(pattern, s): result.append(item.group()) print(result)
Standard input is empty
Standard output is empty
Traceback (most recent call last): File "./prog.py", line 6, in <module> NameError: name 'result' is not defined