#!/usr/bin/python import sys import re import string alphabet = "0" + string.ascii_lowercase goodRe = re.compile("^[0a-z]*$") for s in [s.lower() for s in sys.argv[1:]]: if not goodRe.match(s): print(f"failed to decode {s}: wrong format", file=sys.stderr) continue result = 0 for c in s: result *= 26 result += alphabet.index(c) print(f"{s} = {result-1}")