1 def to_str(n, base): 2 convert_string = "0123456789ABCDEF" 3 if n < base: 4 return convert_string[n] 5 else: 6 return to_str(n / base, base) + convert_string[n % base] 7 8 print to_str(168, 8)