0
Why it can't solve test n°4in ?
I'm stuck in this problem, phone number validator in python , this is my code import re #your code goes here pattern = r"^1|8|9 + [0-9]" num = input() if re.match(pattern , num) and len(num) == 8: print ("Valid") else: print ("Invalid") All test except the fourth one how can I pass
4 Answers
+ 3
# Smile Sam your modified code works well for me:
import re
#your code goes here
pattern = r"^[189]\d{7}quot;
num = input()
if re.match(pattern , num):
print ("Valid")
else:
print ("Invalid")
+ 2
pattern = r"^[189]\d{7}quot;
if re.match(pattern, num):
...
# no need to check length outside of regexp: last $ mean string end, as ^ mean string start ;)
# here is the minimal change needed:
# pattern = r"(1|8|9)[0-9]+"
0
Still the same problem does not work for me
0
visph thanks It is working