0

Phone validator can take 8 digits starting only with 1,8,or 9

import re #your code goes here num=int(input()) pattern=r"[189][0-9]+" if re.match(pattern,"num"): print('Valid') else: print('Invalid')

29th Apr 2021, 9:41 AM
Keerthi goli
Keerthi goli - avatar
3 Réponses
+ 1
delete quotes from num and add ^ $ for mark start end of pattern
29th Apr 2021, 11:05 AM
Илья Мирошник
Илья Мирошник - avatar
0
Your regular expression pattern should reflect that there must be exactly 8 digits, so 7 after the first one. r"[189][0-9]{7}"
29th Apr 2021, 11:05 AM
Tibor Santa
Tibor Santa - avatar
0
Not all these are working I have tried it
29th Apr 2021, 11:27 AM
Keerthi goli
Keerthi goli - avatar