Slip and Slide


def flip_bit(number,n):
mask=(number << n)

  return bin(result)

  print bin(result)

please help me correcting this problem

Replace this line with your code.


We're shifting mask value not number,As elementary maskbit will be 0b1.(Check example given in the exercise)
Also when we shift a number, suppose You shifted 0b1 to 10th ,it actually shifted to 11th position.
That's why we need to subtracted 1 from n so it shifts exactly at n not n + 1.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.