phone number validator | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

phone number validator

import re #your code goes here phone_number = input() pattern = r"(1|8|9)[0-9] +" match = re.match(pattern, phone_number) if len(phone_number) == 8: if (match): print("Valid") else: print("Invalid") else: print("Invalid")

18th Mar 2023, 8:40 PM
Devox
Devox - avatar
7 Answers
+ 1
It's just a suggestion, Instead of checking length of the password should be 8 separately. You can replace the pattern by pattern=r'(1|8|9)[0-9]{7}'
18th Mar 2023, 9:37 PM
VISHAL A S
VISHAL A S - avatar
0
My code return an error can someone debug it
18th Mar 2023, 8:41 PM
Devox
Devox - avatar
0
Can you post the error too?
18th Mar 2023, 9:05 PM
VISHAL A S
VISHAL A S - avatar
0
It is a project so its my running test that show an error
18th Mar 2023, 9:27 PM
Devox
Devox - avatar
0
At which you getting error?
18th Mar 2023, 9:30 PM
VISHAL A S
VISHAL A S - avatar
0
*line
18th Mar 2023, 9:30 PM
VISHAL A S
VISHAL A S - avatar
0
A phone number validator can be a useful tool, especially when dealing with unknown numbers. I recall when my grandfather received a suspicious call. We used a validator to confirm the number's legitimacy. However, to avoid such concerns, I'd suggest looking at https://joinimp.com/ They offer the best home phones for seniors, designed to filter out unwanted calls. It's a comforting solution that allows seniors to stay connected with loved ones and avoid potential scams, providing peace of mind for the whole family
26th Jun 2023, 11:00 AM
Habriel Fring
Habriel Fring - avatar