now my code is not 100% correct way to verify mobile number exactly, update soon
now i checked some condition to confirm given number given number is mobile number.
condition 1 :
given numbers must be only 0 to 9 or + or empty space .
- above the condition is true, then only checks the next conditions.
- otherwise return characters and characters spl are not allow.
condition 2 :
my second condition is checks the length of the given numbers, the length should be 10, then only enter in condition 2. else goes the next condition.
okay, let come's to the condition 2
condition 2 is checks, Given numbers in first number must be greater than or equal to 6 and less than or equal to 9.
- above the condition is true, return "Valid Mobile Number"
- above the condition is false, return "check the first digit"
Condition 3 :
condition 3 also checks the length of the given numbers, the length is must be 13, then only enter in condition 3. else goes the next condition.
let come's to the condition 3
condition 3 is checks the given first three numbers is == "+91"
- Above the condition is False, return "Check the first three numbers"
-
above the condition is true, checks the next condition, next condition is checks the fourth number is must be greater than or equal to 6 and less than or equal to 9.
- the condition is true, return "Valid Mobile Number"
- the condition is false, return "check the fourth digit"
condition 4 :
condition 4 is similar to condition 3, extra checks space
condition 4 checks the length of the given numbers, the length is must be 14, then only enter in condition 4. else goes next .
condition 4,
checks the given first four numbers is == "+91 "
- Above the condition is False, return "Check the first four numbers"
-
above the condition is true, checks the next condition, next condition is checks the fifth number is must be greater than or equal to 6 and less than or equal to 9.
- the condition is true, return "Valid Mobile Number"
- the condition is false, return "check the fifth digit"
FINAL :
given number is can't enter in any condition 2,3,4.
return "given number is invalid"
the function is return a string, So function must be call in print.
and this is my code :
def mobile(n):
i=0
while i<len(n):
if(n[i]>="0" and n[i]<="9") or (n[i]=="+") or (n[i]==" "):
i+=1
else:
return "characters and special charactors not allowed"
if len(n)==10:
if n[0]>="6" and n[0]<="9":
return "valid";
else:
return "First number should not be less then 6 "
if len(n)==13:
if n[0:3]=="+91":
if n[3]>="6" and n[3]<="9":
return "valid"
else:
return "Fourth number should not be less then 6"
return "First three number should like +91"
if len(n)==14:
if n[0:4]=="+91 ":
if n[4]>="6" and n[4]<="9":
return "valid"
else:
return "fifth number should not be less then 6"
return "First four number should like +91 "
return "Please Enter Your valid Mobile Number"
print(mobile(input("Enter Your Mobile Number : ")));
drop your ideas in comments
United States
NORTH AMERICA
Related News
How Braze’s CTO is rethinking engineering for the agentic area
10h ago
Amazon Employees Are 'Tokenmaxxing' Due To Pressure To Use AI Tools
21h ago

Implementing Multicloud Data Sharding with Hexagonal Storage Adapters
15h ago

DeepMind’s CEO Says AGI May Be ~4 Years Away. The Last Three Missing Pieces Are Not What Most People Think.
15h ago

CCSnapshot - A Claude Code Configs Transfer Tool
21h ago