- 3

It's my code to validate phone number in python

import re pattern = r"^(1|8|9)[0-9]+" a = input() if len(a)==8: if re.match(pattern,a): print ("valid") else : print ("invalid") else: print ("invalid")

9th Jun 2021, 8:50 AM
Md Shakil
Md Shakil - avatar
4 Respostas
+ 2
Md Shakil With all due respect, if you don't have a question regarding your code, then this is not the place to post it. Please reserve this thread for code related Q&A only. PS: I haven't tested your code, but it looks clever. Well done!
9th Jun 2021, 9:05 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Md Shakil Your code logic is good, (better than mine) but your output does not meet the challenge requirements. Your outputs -> valid, invalid. Expected outputs -> Valid, Invalid. Good luck
9th Jun 2021, 9:21 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Thanks thanks thanks a lot of thanks It was only the matter of capital letter😂😂
9th Jun 2021, 9:28 AM
Md Shakil
Md Shakil - avatar
- 1
Oh yes I'm sorry for that My question is , why ,in result ,it shows incorrect even my output is as same as the expected output when i put the above code for solving phone number validator in python?? can you tell me what's wrong with that code
9th Jun 2021, 9:13 AM
Md Shakil
Md Shakil - avatar