# Apply a custom gate to qubits in separate quantum registers

Let there be a custom gate (simply called gate that takes $$N$$ qubits as input. Also, let $$A$$ of those qubits be in first_register and $$B$$ of those qubits be in second_register ($$B = N-A$$, obviously). Both registers are QuantumRegisters.

How to append this custom gate to circuit, like what to write in circuit.append(gate, HERE).

## 1 Answer

You can simply merge the lists of qubits from two quantum registers or more as any python lists using "+" sign. For example

gate = UnitaryGate(random_unitary(2 ** 4).data, 'RND-U16')

qr1 = QuantumRegister(2, 'q')
qr2 = QuantumRegister(3, 'a')
circ = QuantumCircuit(qr1, qr2)

circ.mct(qr1[0:2] + qr2[0:2], qr2[2])
circ.append(gate, qr1[1:2] + qr2[0:3])


The result: