Input Format
Locked stub code in the editor reads a single string denoting  from stdin and uses provided expression and your regular expressions to validate if  is a valid postal code.
Output Format
You are not responsible for printing anything to stdout. Locked stub code in the editor does that.

hackerrank validating postal codes problem solution in python programming

Problem solution in Python 3 programming language.

import re
P = input() print(len(re.findall(r'(?=(\d)\d\1)',P)) < 2 and

Second solution

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

Problem solution in Python 2 programming language.

import re
P = raw_input() print len(re.findall(r'(?=(\d)\d\1)',P)) < 2 and