Hello!
Here is how to set the n-th bit to 1
Here is how to set the n-th bit to 1
def set_bit(num, bit_pos): if bit_pos == 1: return num | 1 else: return num | ( 1<<(bit_pos - 1)) selenoids = 0 for n in [1,3,4,7]: selenoids = set_bit(selenoids, n)To unset the n-th bit just copy the same function, change the name to unset_bit and replace '|' with '&'. The first one is bitwise OR and the second is AND.