11. The man behind bit mask



¡Uy! Probá otra vez. Tu función falla en controla_bit4(0b1). Devuelve "on" en vez de devolver "off".

Hi, I have trouble with my code I think that's works.
What's wrong here I can't understand!!!!

def control_bit4(number):
    mask = 0b1100
    desired = mask & number
    if desired > 0:
        return "on"
        return "off"
print control_bit4(0b10)


You have to change name of the function to controla_bit4 (add a).

You were asked to:

Debe revisar si el cuarto bit, comenzando desde la derecha, está encendido.

But your code will check if the fourth or the third bit is on. You have to change the mask to 1000.


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