Hello. I have tried using regex to select based on the format of the tags (xxxx,xxx or xxxx,xxxx) Unsure of how to catch the error if the exact regex form is not equal to the above selections.
tagNum = (input("Enter the tag (q=quit): "))
tagNumRegex = re.compile(r'(\d\d\d\d)-(\d\d\d\d)|(\d\d\d\d)-(\d\d\d)')
mo = tagNumRegex.search(tagNum)
print(mo.groups())
tagOne, tagTwo, tagThree, tagFour = mo.groups()
if(tagOne == "1000"):
print("Entity prefix: PUNS R US")
if(tagTwo == "2000"):
print("Dept prefix: Human Resources")
elif(tagTwo == "3000"):
print("Dept prefix: Accounting")
elif(tagTwo == "4000"):
print("Dept prefix: Service Desk")
elif(tagTwo == "6000"):
print("Dept prefix: Sales")
elif(tagTwo == "7000"):
print("Dept prefix: Management")
elif(tagThree == "2000"):
print("Entity prefix: PUNS-DIRECT")
if(tagFour == "111"):
print("Dept prefix: Service Desk")
if(tagFour == "222"):
print("Dept prefix: Accounting")
if(tagFour == "333"):
print("Dept prefix: E-commerce")
if(tagFour == "444"):
print("Dept prefix: Human Resources")
else:
print("SERR")