Python Code for Mobile Number Validation

1
2
3
4
5
6
7
8
9
10
11
12
13
'''
Created on 02-Oct-2010
@author: anthoniraj
Python Version : 3.1
Description : Script for checking mobile number is valid or not
'''
import re;
mobile = input("Enter the mobile Number:")
p = re.compile('(^[+0-9]{1,3})*([0-9]{10,11}$)')
if p.match(mobile)!= None :
    print("Given Mobile Number is Valid")
else:
    print("Given Mobile Number is  not Valid")

Output:

Enter the mobile Number:9477556235
Given Mobile Number is Valid

Enter the mobile Number:+919865247854
Given Mobile Number is Valid

Enter the mobile Number:-919844576235
Given Mobile Number is  not Valid

Enter the mobile Number:123
Given Mobile Number is  not Valid

Leave a Reply