Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
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.
https://developers.google.com/edu/python/regular-expressions
The first line contains an integer N, the number of inputs.
N lines follow, each containing some string.
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.
2
9587456281
1252478965
YES
NO
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"
# 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')
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'
# 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')
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
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