Skip to content

Instantly share code, notes, and snippets.

@muthu1809
Created July 21, 2020 17:06
Show Gist options
  • Save muthu1809/456f20c5503562f548665b59f98ebdc1 to your computer and use it in GitHub Desktop.
Save muthu1809/456f20c5503562f548665b59f98ebdc1 to your computer and use it in GitHub Desktop.
def isPhoneNumber(text):
if len(text) != 10:
return False
for i in range(0, 9):
if not text[i].isdecimal():
return False
if text[0] == '0':
return False
return True
print('Is 8344777333 a phone number?')
print(isPhoneNumber('8344777333'))
print('Is 0123456789 a phone number?')
print(isPhoneNumber('0123456789'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment