Input Format
The first line contains an integer , the number of inputs.
 lines follow, each containing some string.
Constraints
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.

Hackerrank validating phone numbers in python

Problem solution in python 2 programming language.

import re
for i in range(int(raw_input())):
    print 'YES' if re.search(r"^[789]\d{9}$",raw_input()) else 'NO'

Problem solution in python 3 programming language.

import re
for i in range(int(raw_input())):
    print('YES' if re.search(r"^[789]\d{9}$",raw_input()) else 'NO')