Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save meet100ni/831088ef8187c04d5fba562d7ef9528f to your computer and use it in GitHub Desktop.
Save meet100ni/831088ef8187c04d5fba562d7ef9528f to your computer and use it in GitHub Desktop.
Validating Postal Codes HackerRank Solution
regex_integer_in_range = r"^[1-9]\d{5}$" # Do not delete 'r'.
regex_alternating_repetitive_digit_pair = r"(.)(?=.\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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment