11/17 man behind the bit mask :advanced topic


#1



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


Oops, try again. Does your check_bit4 function take exactly one argument (an integer)? Your code threw a "unsupported operand type(s) for &: 'str' and 'int'" error.


 def check_bit4(input):
    num = bin(input)
    mask = 0b1000
    desired = num & mask
    if desired > 0:
        return "on"
    else:
        return "off"


#2

def check_bit4(input):

mask = 0b1000
desired = input & mask
if desired > 0:
    return "on"
else:
    return "off"

#3

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