from numpy import base_repr def convert(a, b, n): num10 = int(str(n), a) return {a: base_repr(num10, base=b), b: n}