programming-examples/python/Function/Python program to converting an integer to a string in any base.py

8 lines
215 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
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]
print(to_string(2835,16))