I have the following code

for instruction, qargs, cargs in qc.data:
    qbit: qiskit.circuit.Qubit = qargs[0]

the last 2 lines give me a warning:

DeprecationWarning: Back-references to from Bit instances to their containing Registers have been deprecated. Instead, inspect Registers to find their contained Bits.

How can I read them to avoid the warning?


1 Answer 1


The correct way to retrieve the index of a bit within a circuit, and any registers in that circuit the bit is contained within is to call QuantumCircuit.find_bit() as follows:

for instruction, qargs, cargs in qc.data:
    qbit: Qubit = qargs[0]
    bit_location = qc.find_bit(qbit)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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