def check_bit4(i): m = 0b1000 if i&m>0: return "on" else: return "off"
So I know this works. I originally had
def check_bit4(i): i = bin(i) m = 0b1000 if i&m>0: return "on" else: return "off"
Can someone explain why this didn’t work? The error I got was
Does your check_bit4 function take exactly one argument (an integer)? Your code threw a “unsupported operand type(s) for &: ‘str’ and ‘int’” error. As per the instructions, I was presuming I would get an integer as an input and therefore would have to convert the int to a bin