14. Slip and Slide (SOLVED)


#1



https://www.codecademy.com/courses/python-intermediate-en-KE1UJ/2/4?curriculum_id=4f89dab3d788890003000096#


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)


#2

Got it

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


#3

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


#4

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


#5

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