def convert_base(n,b): """ convert_base(int,int) -> str returns the str representation of n (decimal) in base b """ result = "" while n!=0: digit = n%b n//=b result = str(digit)+result return result # convert_base above fails for 10 str returns the str representation of n (decimal) in base 2<=b<=36 """ assert 2<=b<=36, "base is not in range" if n==0: return "0" result = "" while n!=0: digit = n%b n//=b result = \ "0123456789abcdefghijklmnopqrstuvwxyz"[digit]+result return result