Dynamic circuits PF.5.1

Hello,

I was doing the bomb tester exercise with the following code, but I have no idea why I ran into this Error: Your quantum circuit isn’t quite right. I tried postselection as well as resetting the measurement, but it did not work. I would appreciate it if anyone who has had the same issue could help me with this.

n_shots = 10000
dev = qml.device(“default.qubit”, shots=n_shots)
np.random.seed(0)

@qml.qnode(dev)
def circuit():


  qml.Hadamard(0)


  m_bomb = qml.measure(0)

  qml.cond(m_bomb == 0, qml.Hadamard)(0)

  m_det = qml.measure(0)

  return qml.counts(op=[m_bomb,m_det])


results = circuit()

prob_suc = results\[“00”\] / n_shots
print(“The success probability is”, prob_suc) = 0.2495

Hi @farzanmoosavi368 ,

I can see that your circuit is incorrect. Take another look at the diagram and the template for the solution. You don’t need to use qml.cond but you are missing two things. I hope this helps!

1 Like