HackerRank Python - Validating Postal Codes

Your task is to provide two regular expressions regex_integer_in_range and regex_alternating_repetitive_digit_pair

  1. regex_integer_in_range = r'^[1-9][\d]{5}$' # Do not delete 'r'.
  2. regex_alternating_repetitive_digit_pair = r'(\d)(?=\d\1)' # Do not delete 'r'.
  3. import re
  4. P = input()
  5. print (bool(re.match(regex_integer_in_range, P))
  6. and len(re.findall(regex_alternating_repetitive_digit_pair, P)) < 2)
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]

donate a cup of tea :)

Join Our Facebook Group

Share this solution


Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube