int to base

Go Back home
1 from string import hexdigits as H
2 
3 def to_base(i, b):
4     return to_base(i//b, b) + H[i%b] if i else ''
5 
6 print(to_base(10000, 2))
7 print(to_base(10000, 16))