Python allows easy creation of an integer from a string of a given base via
int(str, base).
I want to perform the inverse: creati
def base(decimal ,base) : list = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" other_base = "" while decimal != 0 : other_base = list[decimal % base] + other_base decimal = decimal / base if other_base == "": other_base = "0" return other_base print base(31 ,16)
output:
"1F"