Skip to content

Instantly share code, notes, and snippets.

@rjzak
Created June 14, 2018 22:14
Show Gist options
  • Save rjzak/5319192f7ef8c55f7b7a25222e1dfa5c to your computer and use it in GitHub Desktop.
Save rjzak/5319192f7ef8c55f7b7a25222e1dfa5c to your computer and use it in GitHub Desktop.
Reformat an even-length string, like a MAC address
# Input example: 8249CEB658C71D41D7B734449629AB97
# Output example: 82:49:CE:B6:58:C7:1D:41:D7:B7:34:44:96:29:AB:97
reformat = lambda x: ":".join([x[i:i+2] for i in range(0, len(x), 2)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment