+ 2
Got a question for Python âPhone number validatorâ
You need to find a phone number in the input where it matches the following pattern: It should starts with 1 or 8 or 9 , and the length should be 8 /// import re #your code goes here num = input() pat = r"^[189](/d){7}
quot; if re.match(pat, num): print("Valid") else: print("Invalid") /// So I did this, and somehow itâs wrong. but when I tried pat = râ^[189][0-9]{7}$â and it worked. Could you teach me whatâs the difference? I thought /d also means any digits from 0 to 9.3 Answers
+ 8
pat = r"^[189]\d{7}quot; #debug
+ 3
Vasiliy I feel so stupid right now lol thanks for the answer!
0
Hello guys I can't figure out why Phone Number Validator question of Sololearn can't be solved on the page. This code works on any python editor but refuses on the sololearn page.
This is my code. Anyone who can help me?
import re
#your code goes here
number="57345672"
pattern=r"^[1|8|9]\d{7}quot;
match= re.match(pattern,number)
if(match):
print ("Valid")
else:
print("Invalid")