0

What is wrong with my code. import re #your code goes heri x = (input()) pattern = r"(^1|8|9\d)(......)" if re.match (patte

Phone number validator+help+only one box failed

9th Nov 2020, 10:05 AM
NIGHT LIGHT
6 odpowiedzi
+ 4
What parameters are you trying to get your code to meet. Please explain the challenge associated with your code
9th Nov 2020, 10:27 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
import re #your code goes heri x = (input()) pattern = r"(^1|8|9\d)(......)" if re.match (pattern , x): print ("Valid") else : print ("Invalid") #my full code
9th Nov 2020, 10:06 AM
NIGHT LIGHT
0
I am supposed to make a program that validates phone numbers. It should have 8 digits and start with either 1,8 or 9. It should output Valid if valid or Invalid if not valid.
9th Nov 2020, 11:55 AM
NIGHT LIGHT
0
Following the rules that you mentioned above it should look like , ^[1|8|9]\d{7}
9th Nov 2020, 12:12 PM
Abhay
Abhay - avatar
0
#Abhay It did not work
9th Nov 2020, 12:15 PM
NIGHT LIGHT
0
#found the answer import re #your code goes heri x = (input()) pattern = r"(^1|8|9\d)" if re.match (pattern , x) and len (x)==8: print ("Valid") else : print ("Invalid") #Thanks for helping
9th Nov 2020, 12:17 PM
NIGHT LIGHT