304 North Cardinal St.
Dorchester Center, MA 02124

# Validating phone number Hacker Rank Solution – Queslers

## Problem : Validating phone number Hacker Rank Solution

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 7, 8 or 9.
Concept :A valid mobile number is a ten digit number starting with a 7, 8 or 9.
Regular expressions are a key concept in any programming language. A quick explanation with Python examples is available here. You could also go through the link below to read more about regular expressions in Python.

#### Input Format :

The first line contains an integer N, the number of inputs.
N lines follow, each containing some string.

#### Constraints :

• 1 <= N <= 10
• 2 <= len(number) <= 15

#### Output Format :

For every string listed, print “YES” if it is a valid mobile number and “NO” if it is not on separate lines. Do not print the quotes.

#### Sample Input :

``````2
9587456281
1252478965
``````

#### Sample Output :

``````YES
NO
``````

### Validating phone number Hacker Rank Solution n 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 number Hacker Rank Solution n 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'\d{9}\$',input()):
print('YES')
else:
print('NO')
``````

### Validating phone number Hacker Rank Solution n pypy

``````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'``````

### Validating phone number Hacker Rank Solution n pypy 3

``````# Enter your code here. Read input from STDIN. Print output to STDOUT
import re
N = int(input())
for _ in range(N):
pattern = r'^\d{9}\$'
print ( 'YES' if re.match(pattern,input()) else 'NO')``````
##### Validating phone number Hacker Rank Solution Review:

In our experience, we suggest you solve this Validating phone number Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

Validating phone number is available on Hacker Rank for Free, if you are stuck anywhere between compilation, just visit Queslers to get all Hacker Rank Solution

##### Validating phone number Hacker Rank Solution Conclusion:

I hope this Validating phone number Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Hacker Rank Problem & Solutions >>

Mini-Max Sum Hacker Rank Solution

String Validators Hacker Rank Solution

Text Alignment Hacker Rank solution

String validators Hacker Rank Solution