I have just started working my way through the Codebook.

The following code is being rejected with the error message shown. However, it executes as expected in Visual Studio Code.

I would be hugely grateful of someone could point out my error as it is not possible to progress in the codebook without rectifying the error.

{START}

def measure_state(state, num_meas):

ββ"Simulate a quantum measurement process.

```
Args:
state (array[complex]): A normalized qubit state vector.
num_meas (int): The number of measurements to take
Returns:
array[int]: A set of num_meas samples, 0 or 1, chosen according to the probability
distribution defined by the input state.
"""
##################
# YOUR CODE HERE #
##################
Results = np.empty(num_meas, dtype=int)
# COMPUTE THE MEASUREMENT OUTCOME PROBABILITIES
Ket0Probability = np.real(state[0]*(state[0].conjugate())
# RETURN A LIST OF SAMPLE MEASUREMENT OUTCOMES
Results = np.random.choice(2, num_meas, p=[Ket0Probability, (1-Ket0Probability)])
return Results
```

state = np.array([0.8, 0.6])

num_meas = 10

print(measure_state(state,num_meas))

{END}

The error is βError: invalid syntax (, line 20)β

Line 20 is the call to np.random.choice

I have tried Line 20 with β2β replaced with [0,1].

I have tried Line 20 dropping βp=β.

All four variants work in Visual Studio Code.

Thanks in advance,

Simon