Possible Duplicate:
convert integer to a string in a given numeric base in python
I want to work with base 5 numbers, or any other non standard base for that matter.
I found out int('123', 5)
works, but I need to go the other way around.
Should I write my own number class to accomplish this?
Maybe I'm just thinking in the wrong direction...
def to_base_5(n):
s = ""
while n:
s = str(n % 5) + s
n /= 5
return s
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With