Write a Python function to converting an integer to a string in any base.


Topic: Write a Python function to converting an integer to a string in any base.

Solution

def to_string(n,base):
   conver_tString = "0123456789ABCDEF"
   if n < base:
      return conver_tString[n]
   else:
      return to_string(n//base,base) + conver_tString[n % base



List all Python Programs