Hi i would like to add leading zeros into binary to make it to have 8 digits. I've tried using zfill()
but it doesnt seem to work and i have no idea how to use format()
cause all the answers i've found are all keeping the 0b
which i dont want that.
Here's what i've tried:
lenToBin = bin(payloadLength).replace("0b", "")
if payloadLength == 30 or payloadLength == 31:
binResult = lenToBin.zfill(3)
else:
binResult = lenToBin.zfill(2)