

str1 = 'a23'
if str1[0].isdecimal():
print('Yes')
else:
print('No')
class Error(Exception):
"""Base class for other exceptions"""
pass
class lenghtError(Error):
"""incorrect length"""
pass
def testPhone(te):
for i in range(11):
if i == 4 or i == 8:
if str(te[i])=='-':
a = True
else:
return False
if i != 4 or i != 8:
if str(te[i]).isdecimal() == True:
a = True
else:
return False
return a
while True:
try:
tele = str(input("Enter a number: "))
if len(tele) != 12:
raise lenghtError
print('length error')
if testPhone(tele)==True:
break
else:
print('format error')
except Error as e:
print(e)
else:
break
print("format correct")






? = can be ignored
‘*’ = non to many
‘+’=1 to many
{N}=()times N number , must be satisfied


search is to get the first one only
findall is to get all

