forked from arsho/Hackerrank_Python_Domain_Solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Validatingphonenumbers.py
32 lines (32 loc) · 913 Bytes
/
Validatingphonenumbers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'''
Title : Validating phone numbers
Subdomain : Regex and Parsing
Domain : Python
Author : Ahmedur Rahman Shovon
Created : 15 July 2016
Problem : https://www.hackerrank.com/challenges/validating-the-phone-number/problem
'''
# Enter your code here. Read input from STDIN. Print output to STDOUT
n=int(raw_input())
for i in range(0,n):
tmp_str=raw_input()
len_tmp_str=len(tmp_str)
if(len_tmp_str!=10):
##print "LENGTH PROBLEM"
print "NO"
elif(tmp_str[0]!="7" and tmp_str[0]!="8" and tmp_str[0]!="9"):
##print "START PROBLEM"
print "NO"
else:
check=1
for i in tmp_str:
if(i>="0" and i<="9"):
continue
else:
check=0
break
if(check==1):
print "YES"
else:
##print "NUMBER PROBLEM"
print "NO"