Program to toggle K | Function to toggle the kth bit of n ; Driver code
def toggleBit ( n , k ) : NEW_LINE INDENT return ( n ^ ( 1 << ( k - 1 ) ) ) ; NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT n = 5 ; k = 2 ; NEW_LINE print ( toggleBit ( n , k ) ) ; NEW_LINE DEDENT