Hello, without running the code can you identify which line throws an error?
wires = 4
dev4 = qml.device("default.qubit", wires=wires)
@qml.qnode(dev4)
def ghz_circuit():
qml.Hadamard(wires=0)
...
exp_vals = [qml.expval(qml.PauliZ(i)) for i in range(wires)]
exp_vals = [qml.expval(qml.PauliZ(i) for i in range(wires))]
return exp_vals
Well the difference between:
exp_vals = [qml.expval(qml.PauliZ(i)) for i in range(wires)]
and exp_vals = [qml.expval(qml.PauliZ(i) for i in range(wires))]
is very subtle.
The correct form is of course:
exp_vals = [qml.expval(qml.PauliZ(i)) for i in range(wires)]
Best,