• + 0 comments

    \1 can be used inside of the lookahead even if the group is declared outside of it, wich enhance visibility and compehensiveness in that case.

    regex_integer_in_range = r"^[1-9]{1}[0-9]{5}$"
    regex_alternating_repetitive_digit_pair = r"(.)(?=.\1)"
    
    
    import re
    P = input()
    
    print (bool(re.match(regex_integer_in_range, P)) 
    and len(re.findall(regex_alternating_repetitive_digit_pair, P)) < 2)