# In case you get: AttributeError: 'generator' object has no attribute 'is\_hermitian'

**URL:** <https://discuss.pennylane.ai/t/in-case-you-get-attributeerror-generator-object-has-no-attribute-is-hermitian/3033>\
**Category:** PennyLane Help\
**Created:** [June 10, 2023, 7:11pm UTC](https://discuss.pennylane.ai/t/in-case-you-get-attributeerror-generator-object-has-no-attribute-is-hermitian/3033 "2023-06-10T19:11:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Solomon](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/solomon/32/1706_2.png) [@Solomon](https://discuss.pennylane.ai/u/Solomon)\
**Post date:** [June 10, 2023, 7:11pm UTC](https://discuss.pennylane.ai/t/in-case-you-get-attributeerror-generator-object-has-no-attribute-is-hermitian/3033/1 "2023-06-10T19:11:47Z")

</div>

Hello, without running the code can you identify which line throws an error?

```auto
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:

```auto
exp_vals = [qml.expval(qml.PauliZ(i)) for i in range(wires)]

```

Best,

---

<div class="post-metadata">

**Author:** ![isaacdevlugt](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/isaacdevlugt/32/1159_2.png) [@isaacdevlugt](https://discuss.pennylane.ai/u/isaacdevlugt)\
**Post date:** [June 12, 2023, 2:38pm UTC](https://discuss.pennylane.ai/t/in-case-you-get-attributeerror-generator-object-has-no-attribute-is-hermitian/3033/2 "2023-06-12T14:38:49Z")

</div>

Thanks @Solomon! Nice to have posts like this for people to reference in the future 😁
