# How to undo an operation in qiskit on jupyter notebook?

I am not able to undo an operation. For example, I want a single Hadamard gate on a single qubit but by mistake two Hadamard gate added. Now I want to remove one of them without interrupting kernel. Is there any easy way. Please help me. Thank you.

• Could you elaborate a bit? Inside a jupyter notebook, you could easily remove a gate from your code by removing a line such as circuit.h(0). – Francois Jul 29 '20 at 10:16
• Yes! That is exactly what I wanted to say. Thank you – Satish Kumar Dubey Jul 29 '20 at 14:11

To remove the last gate you can do qc.data.pop().

Example:

qc = QuantumCircuit(1)
qc.h(0)
qc.draw('text')


output:

     ┌───┐
q_0: ┤ H ├
└───┘


Then:

qc.data.pop()
qc.draw('text')


output:

q_0:

• Thank you very much @Frank. It helps a lot for beginners like me. – Satish Kumar Dubey Jul 29 '20 at 14:18