I need help on Phone Number Validator [Python] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I need help on Phone Number Validator [Python]

so, this is my last code project to complete python core path, why it is throwing syntax error here at line 5? here is my code ``` import re #your code goes here num = int(input("type number") pattern = r"\A(1|8|9)\d{7}

quot; match = re.search(pattern, num) if match: print("valid") else: print("Invalid") ```

23rd Oct 2022, 5:01 PM
Nabin Bhatt
Nabin Bhatt - avatar
1 Answer
+ 1
0h no! I forgot to close the bracket. also, I managed to solve this challenge, here is the final code :) import re #your code goes here num = input() pattern = r"\A[1|8|9]\d{7}
quot; valid = re.search(pattern, num) if valid: print("Valid") else: print("Invalid")
23rd Oct 2022, 5:16 PM
Nabin Bhatt
Nabin Bhatt - avatar