String Formatting

  • + 1 comment

    This code gives an error, "TypeError: unsupported operand type(s) for -: 'str' and 'int'"

    Someone please tell me what it is and how to fix it.

    number = int(input())
    
    for i in range(1, number+1):
        print(str(i).rjust(len(bin(i) - 2)))
        print(oct(i)[2:].rjust(len(bin(i) - 2)))
        print(oct(i)[2:].rjust(len(bin(i) - 2)))
        print(oct(i)[2:].rjust(len(bin(i) - 2)))