How to use 'decimal to n base conversion program in python' in Python

Every line of 'decimal to n base conversion program in python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
247def convertbase(number,base=10):
248 integer=number
249 if not integer:
250 return '0'
251 sign=1 if integer>0 else-1
252 alphanum=string.digits+string.ascii_lowercase
253 nums=alphanum[:base]
254 res=''
255 integer*=sign
256 while integer:
257 integer,mod=divmod(integer,base)
258 res+=nums[mod]
259 return('' if sign==1 else '-')+res[::-1]

Related snippets