-
Notifications
You must be signed in to change notification settings - Fork 242
Update Validatingphonenumbers.py #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Updated Code to Python3 standards.
Added 'Updated' Date
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please accommodate the review comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following code is using regex. Please update the PR with this:
from re import compile, match
n = int(input())
for _ in range(n):
phone_number = input()
condition = compile(r'^[7-9]\d{9}$')
if bool(match(condition, phone_number)):
print("YES")
else:
print("NO")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Regex solution added as suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Splendid!
Updated Code to Python3 standards.