HackerRank Validating phone numbers solution in Python YASH PAL, 31 July 202417 January 2026 HackerRank Validating phone numbers solution in Python – In this Validating phone numbers problem, you are given some input, and you are required to check whether they are valid mobile numbers.Let’s dive into the interesting topic of regular expressions! You are given some input, and you are required to check whether they are valid mobile numbers. A valid mobile number is a ten digit number starting with a or .ConceptA valid mobile number is a ten digit number starting with a or . Regular expressions are a key concept in any programming language. You could also go through the link below to read more about regular expressions in Python.Input FormatThe first line contains an integer N, the number of inputs.N lines follow, each containing some string.HackerRank Validating phone numbers solution in Python 2.import re n = int(raw_input()) for x in range(0, n): if(re.match(r'^[7-9]{1}[0-9]{9}n?r?$', raw_input())): print "YES" else: print "NO"Validating phone numbers problem solution in Python 3.# Enter your code here. Read input from STDIN. Print output to STDOUT import re for _ in range(int(input())): if re.match(r'[789]d{9}$',input()): print('YES') else: print('NO')Problem solution in pypy programming.import re n = int(raw_input()) for i in range(n): s = raw_input() print ‘YES’ if re.match(r’^[7-9]d{9}$’, s) else ‘NO’Problem solution in pypy3 programming.# Enter your code here. Read input from STDIN. Print output to STDOUT import re N = int(input()) for _ in range(N): pattern = r'^[789]d{9}$' print ( 'YES' if re.match(pattern,input()) else 'NO') coding problems solutions Hackerrank Problems Solutions Python Solutions HackerRankPython