Last active
July 19, 2016 12:58
-
-
Save BlueNexus/c354d1a1bef7bc26b4181eb966efb2e7 to your computer and use it in GitHub Desktop.
Determines registration date and location when given an irish license plate number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
index_codes = { | |
"C":"Cork", "CE":"Clare", | |
"CN":"Cavan", "CW":"Carlow", | |
"D":"Dublin", "DL":"Donegal", | |
"G":"Galway", "KE":"Kildare", | |
"KK":"Kilkenny", "KY":"Kerry", | |
"L":"Limerick", "LD":"Longford", | |
"LH":"Louth", "LM":"Leitrim", | |
"LS":"Laois", "MH":"Meath", | |
"MN":"Monaghan", "MO":"Mayo", | |
"OY":"Offaly", "RN":"Roscommon", | |
"SO":"Sligo", "T":"Tipperary", | |
"W":"Waterford", "WH":"Westmeath", | |
"WX":"Wexford", "WW":"Wicklow" | |
} | |
def parse_plate(to_parse): | |
final = "" | |
try: | |
for section in to_parse: | |
worktext = "" | |
if to_parse.index(section) == 0: | |
if len(section) == 3: | |
working = section[:2] | |
worktext += ("20" + str(working)) | |
working = section[2] | |
if working == 1: | |
worktext += " Jan-June" | |
else: | |
worktext += " Jul-Dec" | |
else: | |
if int(section[0]) <= 1: | |
worktext = "20" + str(section) | |
else: | |
worktext = "19" + str(section) | |
else: | |
for key, value in index_codes.items(): | |
if section == key: | |
worktext = "registered in " + value | |
final += worktext + " " | |
except: | |
print("Invalid plate") | |
print(final) | |
def main(): | |
while True: | |
plate = str(input("Enter the full license plate:")) | |
s_plate = plate.split("-") | |
if len(s_plate) == 3: | |
break | |
del s_plate[2] | |
parse_plate(s_plate) | |
while True: | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment