When I call this function in an attempt to try to build and troubleshoot. You know so I can actually see what is going on. I get the following error
"Oops, try again. Your code looks a bit off (pun super intended)--it threw a "unsupported operand type(s) for ^: 'str' and 'int'" error. Check the Hint if you need help!"
I expect line 4 "print bin(desired)" to print to console so I can see what is actually going on since return is not sent to the console window.
Again I don't understand how new people with no coding experience are A. supposed to figure this one out on their own with the instructions that have been given to this point if they can not print to console to see what is going on and dont scrape the net for answers.
If I break it and I loop at the error given. I am calling EXACTLY what the one of the tests is calling but yet it does not work.
'Oops, try again. Your function fails on flipbit('0b111', 2). It returns "0b11101100" when it should return "0b101".'_
Again after searching the net people have been complaining about this problem for years and yet the wording and the problem itself appear to be unchanged. Just baffling. People are not learning anything from this problem and there is no way people are green horns are solving this without help or understanding what is going on. Very frustrating.
Yes it is free that's great but if you are going to bother making something to begin with why not make it worthwhile.
def flip_bit(number, n): mask = (0b1 << n-1) desired = number ^ mask print bin(desired) return bin(desired) flip_bit('0b111', 2)