0
$\begingroup$

I am running a simple 3 qubit circuit which produces the following results:

{'000': 5, '001': 3, '010': 10, '100': 5, '101': 7, '110': 7, '111': 4}

There are no counts of 011. Is there a simple way within qiskit to also return the result '011': 0? So the final results would be

{'000': 5, '001': 3, '010': 10,'011': 0, '100': 5, '101': 7, '110': 7, '111': 4}

Currently when I run this circuit I get an error as I am trying to call res['011'], where res is the list of results. I cannot just increase the number of shots unfortunately I am constrained to this number of qubits.

$\endgroup$
2
$\begingroup$

You can use .get() and return zero as the default value.

res.get('011', 0)

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.