14. Slip and Slide (SOLVED)



Oops, try again. Your function fails on flip_bit('0b111', 2). It returns "0b1" when it should return "0b101".

I'm not sure about the code. I found the instructions a bit vague

def flip_bit(number, n):
    result = number << n
    return bin(result)


Got it

def flip_bit(number, n):
    result = 0b1 << n-1
    desired = number ^ result
    return bin(result)


Did it work for you?I entered this code and it threw an error:confused:


That's because there is a small error in the code snipplet. The function has to return desired.


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