-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumFinder.py
More file actions
35 lines (29 loc) · 779 Bytes
/
NumFinder.py
File metadata and controls
35 lines (29 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
def isPhoneNumber(text):
if len(text) != 12:
return False
for i in range(0, 3):
if not text[i].isdecimal():
return False
if text[3] != '-':
return False
for i in range(4, 7):
if not text[i].isdecimal():
return False
if text[7] != '-':
return False
for i in range(8, 12):
if not text[i].isdecimal():
return False
return True
print("Input:")
message = input()
print("\nSearching for Numbers...\n")
foundNumber = False
for i in range(len(message)):
load = message[i:i+12]
if isPhoneNumber(load):
print(f"Phone Number {load} found!")
foundNumber = True
if not foundNumber:
print("Phone number was not found.")