Skip to content

Instantly share code, notes, and snippets.

@david-lev
Last active November 10, 2021 22:32
Show Gist options
  • Save david-lev/f4cc8544422a39c704dd6fb4e10bec69 to your computer and use it in GitHub Desktop.
Save david-lev/f4cc8544422a39c704dd6fb4e10bec69 to your computer and use it in GitHub Desktop.
Convert mac-address to device id
chars = {
"0": "00",
"1": "01",
"2": "02",
"3": "03",
"4": "04",
"5": "05",
"6": "06",
"7": "07",
"8": "08",
"9": "09",
"A": "10",
"B": "11",
"C": "12",
"D": "13",
"E": "14",
"F": "15"
}
def convert(mac_addr: str) -> str:
device_id = str()
for char in mac_addr.upper():
if chars.get(char):
device_id += chars.get(char)
else:
device_id += char
return device_id
print(convert(input("Please enter your mac address: ")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment