I have the following storage in Python (20 x 1):
storage = 0b11111111111111111111
How to make this more dynamic? How to initialize it with e.g. 30 oder 40 bits without typing 1 forty times, that is.
>Solution :
You can use the bit shift operator, like this:
storage = (1 << 40) - 1
Replace 40 with the number of bits.
EDIT: As mentioned in @slothrop’s comment, there’s also another solution:
storage = 2**40 - 1