Creating a Phone Number Validator using Python3

What is a Phone Number Validator?

A phone number validator simply checks the number for the given criteria and returns true if the criteria is satisfied.


Sound  Simple ? Let's get started

"""You are given a number input, and need to check if it is a valid phone number.
A valid phone number has exactly 10 digits and starts with 7, 8 or 9. 
Output "Valid" if the number is valid and "Invalid", if it is not. 

Sample Input
8123987012

Sample Output 
Valid
"""

a = input()
if len(a) == 10:
  if a[0] in "789":
    print("Valid")
  else:
    print("Invalid")

0 Comments