Here is the code I've just implemented. This is not a method but you can use it as a ready-to-use function!
def inttobinary(number): if number == 0: return str(0) result ="" while (number != 0): remainder = number%2 number = number/2 result += str(remainder) return result[::-1] # to invert the string