Check if Binary representation is Palindrome

def binaryPallindrome(num):

binary = bin(num)

binary = binary[2:]

return binary == binary[-1::-1]

if __name__ == "__main__":

num = 9

print (binaryPallindrome(num))


No comments: