HackerRank Python - Validating phone 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 7, 8 or 9.

  1. # Enter your code here. Read input from STDIN. Print output to STDOUT
  2. import re
  3. [print('YES' if re.match(r'[789]\d{9}$', input()) else 'NO') for _ in range(int(input()))]

download android app