10 Digit Mobile Number Validation in PythonIntroduction:In this article, we are discussing how to check 10 digit mobile number validation in Python. Here we are only checking the validation of 10 digit mobile number. The mobile number is 7894561230. There are some criteria for validating mobile number, which is -
When the 0 digits add at the front of any mobile number, then this is 12 digit mobile number, and it is also validating number. Algorithm 1 of checking validation of mobile number:Here we share the algorithm for checking the validation of mobile numbers. We have done it using Python programming language. In Python, there is various kind of modules. 're' module is one of them. This module is used for matching the pattern. The steps for checking the validation of the mobile number are given below -
Program code for checking the validation of a mobile number using the above algorithm:Some examples of checking the validation of a mobile number are given below - Example 1: Here we give an example of checking the validation of a mobile number in Python. We import re module for this program. The code is given below - Output: Now we compile the above code in Python, and after successful compilation, we run it. Then the output is given below - Enter a Mobile number :7894561230 This is a valid mobile number Example 2: Here we give another example of checking the validation of a mobile number in Python. We import re module for this program. The code is given below - Output: Now we compile the above code in Python, and after successful compilation, we run it. Then the output is given below - This is an invalid mobile number Example 3: Here we give another example of checking the validation of a mobile number in Python. We import re module for this program. The code is given below - Output: Now we compile the above code in Python, and after successful compilation, we run it. Then the output is given below - Enter the phone number: 2894561230 This is an invalid mobile number Example 4: Here we give another example of checking the validation of a mobile number in Python using the '[6-9][0-9]{9}' pattern. We import re module for this program. The code is given below - Output: Now we compile the above code in Python, and after successful compilation, we run it. Then the output is given below - Enter a Mobile number :2894561230 This is not a valid mobile number Algorithm 2 of checking validation of mobile number:Here we share another algorithm for checking the validation of mobile numbers. We have done it using Python programming language. In Python, there is various kind of modules. 're' module is one of them. This module is used for matching the pattern. The steps for checking the validation of the mobile number are given below -
Now we give an example using the above algorithm to check list of numbers is valid or not. Example: Here we give an example of checking the validation of a mobile number in Python using the above algorithm. We import re module for this program and create a function. The code is given below - Output: Now we compile the above code in Python, and after successful compilation, we run it. Then the output is given below - 7894561230 is a valid mobile number 28945612301 is not a valid mobile number 0894561230 is a valid mobile number 9894561230 is a valid mobile number 78945h1230 is not a valid mobile number 78@4561230 is not a valid mobile number Algorithm 3 of checking validation of mobile number using numpy:Here we share another algorithm for checking the validation of mobile numbers using numpy. The steps for checking the validation of the mobile number are given below -
Example: Here we give an example of checking the validation of a mobile number in numpy using the above algorithm. The code is given below - Output: Now we compile the above code in Python, and after successful compilation, we run it. Then the output is given below - 2894561230 It is not a valid mobile number Conclusion:In this article, we are discussing how to check 10 digit mobile number validation in Python. Here we have three different approaches to checking whether the number is validated. But the condition of the validated mobile number is always the same: the number must be started between 6 to 9, any number, and the rest digits of the validated mobile number must be started between 0 to 9, any number. And also, there must not be any special character and alphabet. |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India