import re

s = "0207a97"
l = [i for i in re.findall('\d+',s) if '9' not in i]
if len(l)>0:
    print(max(l, key=int))
    