11. The man behind the mask is giving me pronlems


#1



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

My code keeps returning the wrong value, Can someone please explain what I'm doing wrong


def check_bit4(inpt):
    mask=0b1010
    bit = mask & inpt
    if bit >0:
        return 'on'
    else:
        return 'off'

Oops, try again. Your function fails on check_bit4(0b10). It returns "on" when it should return "off".


#2

@makmash,
Maybe if you read a bit
https://discuss.codecademy.com/t/14-14-error/9294/4?u=leonhard.wettengmx.n

https://discuss.codecademy.com/t/13-make-sure-your-answer-is-a-binary-string/9462/2?u=leonhard.wettengmx.n

https://discuss.codecademy.com/t/slip-and-slide-whats-wrong-with-this/32677/2?u=leonhard.wettengmx.n

With a google search
== discussions / opinions ==
python bit mask explained site:stackoverflow.com


#3

Thank you very much, that helped in figuring out that tiny mistake I was making, reading more is appearantly the key :grinning:


#4

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