Created
May 13, 2020 13:25
-
-
Save meet100ni/831088ef8187c04d5fba562d7ef9528f to your computer and use it in GitHub Desktop.
Validating Postal Codes HackerRank Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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