Say, I have a list of operations which are pennylane gates, can I create a circuit from it?
import pennylane as qml operations=[qml.Hadamard(wires=2),qml.PauliX(wires=),qml.PauliX(wires=),qml.CNOT(wires=[1, 2])] def circuit(): operations for op in operations: op qml.Hadamard(wires=) return qml.expval(qml.PauliZ(0)) dev=qml.device('default.qubit',wires=4) circuit=qml.QNode(circuit, dev) print(qml.draw(circuit)())
This seems not to work. Only the Hadamard on wire 3 is drawn. I do not understand what difference it makes whether I write the gate directly into the circuit or first in a list and then insert it into the circuit.
Is there another way to do this?