Created
January 18, 2019 11:54
-
-
Save aphexmunky/c8a070385fb015cf6fd3bd8f89700c25 to your computer and use it in GitHub Desktop.
python int to base conversion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def toStr(n,base): | |
convertString = "0123456789ABCDEF" | |
if n < base: | |
return convertString[n] | |
else: | |
return toStr(n//base,base) + convertString[n%base] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment