+ 72

Python problem [ Solved ]

Hay freinds I was trying to do my RE problem of python course. Which is last 2nd que of the python course https://www.sololearn.com/Course/Python/?ref=app My try \/ import re #your code goes here a = input() pk = re.findall("^[189]\d{7}",a) if len(pk) != 0: print("Valid") else: print("Invalid") But 1 test case is failing continually. Can anyone help me to solve this. Code problem name : Phone Number Validator Position : last second problem of python course

11th Oct 2020, 5:06 AM
Ayush Kumar
Ayush Kumar - avatar
7 Answers
+ 10
Your code is almost done: You just need to add the $ at the end of your expression to match the end of the line. Furthermore, consider use re.match() because you only need one match.
12th Oct 2020, 1:06 PM
YUCCA
YUCCA - avatar
+ 12
Rishu Tiwary please answer šŸ„ŗšŸ„ŗ
11th Oct 2020, 10:57 AM
Demi lunešŸŒ™
Demi lunešŸŒ™ - avatar
+ 8
Can you copy paste the question I am not able to understand which question are you talking about šŸ¤”
11th Oct 2020, 1:27 PM
Namit Jain
Namit Jain - avatar
+ 4
You can check this code Hope that it will get you https://code.sololearn.com/cUYud6IqzDHC/?ref=app
11th Oct 2020, 6:47 PM
Indranil
Indranil - avatar
+ 2
Use iteration! for I in range(len(a)):
22nd Oct 2021, 5:45 AM
ŠŸŠ°Š²ŠµŠ» Š‘Š»Š°Š³Š°Ń€ŃŒ
ŠŸŠ°Š²ŠµŠ» Š‘Š»Š°Š³Š°Ń€ŃŒ - avatar
+ 1
import re a = input() pk = re.findall("^[189]\d{7}
quot;,a) if len(pk) !=0: print("Valid") else: print("Invalid") I tried this. Its right.
1st May 2021, 12:25 PM
Halima Vohra
Halima Vohra - avatar