Question: I have binary string which is "00000000000000001011000001000010".
I want to convert this string to byte array and from that byte array,I want to obtain corresponding float value. How it can be done in python? 

I tried doing it using `struct.unpack()`.

```
def bitstring_to_bytes(s):
    v = int(s, 2)
    b = bytearray()
    while v:
        b.append(v & 0xff)
        v >>= 8
        return bytes(b[::-1])

>>> s="00000000000000001011000001000010"
>>> print(bitstring_to_bytes(s))
>>> B
>>> struct.unpack('>f',B)

```

Also guide me on getting float value from byte array.
Finally, we should obtain float value=88.0

Answer: 
You can use [`Event.preventDefault()`](https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault). You also have to check the value to allow space afterwords.

```js
var userAnswer = document.querySelector('.user-answer');
window.addEventListener('keypress', myFun);

function myFun(e) {
  if(e.keyCode === 32 && (e.target.value == undefined || e.target.value == "")) {
    e.preventDefault();
    userAnswer.focus();
  }
}
```

```html
<input type="text" class="user-answer" name="useranswer">
```
You could prevent the default from happening which would be adding the space in this example.

```
function myFun(e) {
    if(e.keyCode === 32 && userAnwer.value.length == 0) {

        e.preventDefault();

        userAnwer.focus();
    }
}

```