Here is my code

import numpy as np
import qiskit
from qiskit import *

number_of_qubits = 3
backend_sim = Aer.get_backend('qasm_simulator')

#Generate a circuit in qiskit
input_circuit = QuantumCircuit(number_of_qubits, number_of_qubits)

job_sim = execute(input_circuit, backend_sim, shots=1024)
result_sim = job_sim.result()
counts = result_sim.get_counts(input_circuit)

No matter what gates I try (e.g. I can remove the last X gate), the result is always '000': 1024. What am I doing wrong?


Your current circuit looks like this:

example circuit without measurements

In order to get the "counts", you need to measure at the end of the circuit, before execute.

input_circuit.measure(range(number_of_qubits), range(number_of_qubits))

Example circuit with measurements

| improve this answer | |
  • $\begingroup$ Ah, makes sense! Thank you! $\endgroup$ – user1936752 Sep 11 at 19:23

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.