-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmsUtils.py
More file actions
40 lines (40 loc) · 935 Bytes
/
smsUtils.py
File metadata and controls
40 lines (40 loc) · 935 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
36
37
38
39
40
def fix_phone_num(phone_num):
if len(phone_num) == 10:
try:
int(phone_num)
is_good = True
except:
is_good = False
if is_good:
return "+1" + phone_num
#return "ERROR: 10 length but isn't all numbers"
return False
elif len(phone_num) == 11:
if phone_num[0] == "1":
try:
int(phone_num)
is_good = True
except:
is_good = False
if is_good:
return "+" + phone_num
#else:
# return "ERROR: phone # part isn't all numbers"
#return "ERROR: 11 length but doesn't start with 1"
return False
elif len(phone_num) == 12:
if phone_num[0] == "+" and phone_num[1] == "1":
try:
int(phone_num[1:])
is_good = True
except:
is_good = False
if is_good:
return phone_num
#else:
# return "ERROR: phone # part isn't all numbers"
#return "ERROR: 12 length but doesn't start with +1"
return False
else:
#return "ERROR: Not of 10, 11, or 12 length."
return False