Reverse number in binary implemented in python