+ 2
help please
Im in the python core's project "Phone Number Validator",there are 5 cases and i completed 4 but the number 3 gives me an error and its the only one and i dont know what should be the answer because its block.If someone could help me please. Here is my code: import re numero=str(input()) patron=r"^[1|8|9]" if re.match(patron,numero): print("Valid") else: print("Invalid")
16 Respuestas
+ 2
#check this out
# fix ur pattern and combine ur conditions
import re
num = input ()
pattern = r"^[1|8|9][0-9]*quot;
if re.match(pattern,num) and len(num)==8:
print("Valid")
else:
print("Invalid")
+ 2
Oh right that idea pass over my mind but im too lazy to code it
+ 1
*I'm proud of you, sorry 😁 (my translator is naughty)
+ 1
Oh ok,thank you very much im gonna check that error
+ 1
import re
string=input()
pattern=r"[\1|8|9](\d{7})"
match=re.match(pattern,string)
if match:
print("Valid")
else:
print("Invalid")
0
Hi! You check phone number by only 8 symbols?
0
😆 And I'm just busy working on your brilliant code right now 😉
0
Oh thanks you didnt have to.Anyway i added the the 8 number's checker but it still given me error but the other are good.
0
and how do you perform the verification?
0
like this:
import re
numero=str(input())
patron=r"^[1|8|9]"
if len(numero)>=8:
if re.match(patron,numero):
print("Valid")
else:
print("Invalid")
else:
print("Invalid")
0
you have an error in the comparison operator. be careful! But on the whole, I'm good for you!
0
Oh thank you very much evg-san,now i have to figure it out how your code works.But i dont realize yet why my code doesnt work yet
0
Thank yu very much Itech you make me understand that i have to combine and use more conditions
0
u welcome. when u need help, u can inbox me, i will reply ASAP.
0
from re import match as k
if k(r"[189]\d{7}quot;, input()): print("Valid")
else: print("Invalid")
""" Hope this helps; passes all the test cases. The 3rd test case ends with a non-digit. Including the dollar sign solves that """
- 2
This is my variant in one string:
...check = len()
if re.match() and check == 8:
...