0

Python Course, Phone Number Validator Question - What could "test case 3 be"?

Hi, I wrote this code as an answer: import re #your code goes here pattern = r"\A(1|8|9)\d{7}" number = input() if re.match(pattern, number): print("Valid") else: print("Invalid") (not working) r"\A(1|8|9)\d{7}" (works) r"\A(1|8|9)\d{7}

quot; What does "
quot; change that the test case 3 gives no error? I mean... what could Test Case 3 be? I tried putting "\Z" but didn't work. Please enlighten me about the possible causes. ;-;

9th Apr 2021, 2:03 PM
Gökdeniz
Gökdeniz - avatar
2 Antworten
+ 1
$ mean end of text, that after 7 digitals (d{7}) no more text or nums
9th Apr 2021, 3:32 PM
Илья Мирошник
Илья Мирошник - avatar
+ 1
U need mark start of string too by ^, but u use \A (for text)
9th Apr 2021, 3:34 PM
Илья Мирошник
Илья Мирошник - avatar