# Help: A problem

**URL:** <https://discuss.pennylane.ai/t/help-a-problem/1396>\
**Category:** PennyLane Help\
**Created:** [October 8, 2021, 6:06am UTC](https://discuss.pennylane.ai/t/help-a-problem/1396 "2021-10-08T06:06:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![RX1](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/rx1/32/698_2.png) [@RX1](https://discuss.pennylane.ai/u/RX1)\
**Post date:** [October 8, 2021, 6:06am UTC](https://discuss.pennylane.ai/t/help-a-problem/1396/1 "2021-10-08T06:06:09Z")

</div>

![image](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/1X/eaf59e1d62f6fdba5f53a6f2b5b15d4bdee8a50a.png)

```auto
--------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-23-15dc944c6be8> in <module>
----> 1 circuitBasis(pparams)

D:\Anaconda3\lib\site-packages\pennylane\qnode.py in __call__ (self, *args, **kwargs)
    665 if self.mutable or self.qtape is None:
    666 # construct the tape
--> 667 self.construct(args, kwargs)
    668 
    669 # If the observable contains a Hamiltonian and the device does not

D:\Anaconda3\lib\site-packages\pennylane\qnode.py in construct(self, args, kwargs)
    577 
    578 with self.qtape:
--> 579 self.qfunc_output = self.func(*args, **kwargs)
    580 
    581 if not isinstance(self.qfunc_output, Sequence):

<ipython-input-22-62e7b3038ff9> in circuitBasis(params)
      5 def circuitBasis(params):
      6 qml.BasisState(params, wires = [0, 1, 2, 3])
----> 7 return [qml.expval(qml.PauliZ(i) for i in range(4))]

D:\Anaconda3\lib\site-packages\pennylane\measure.py in expval(op)
    253 if not isinstance(op, (Observable, qml.Hamiltonian)):
    254 raise qml.QuantumFunctionError(
--> 255 "{} is not an observable: cannot be used with expval".format(op.name)
    256 )
    257 

AttributeError: 'generator' object has no attribute 'name'

```

---

<div class="post-metadata">

**Author:** ![josh](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/josh/32/100_2.png) [@josh](https://discuss.pennylane.ai/u/josh)\
**Post date:** [October 8, 2021, 6:52am UTC](https://discuss.pennylane.ai/t/help-a-problem/1396/2 "2021-10-08T06:52:58Z")

</div>

Hi @RX1! It seems to be a small syntax error in your QNode return 🙂 Note that the `for i in range(4)` should occur _outside_ the `expval` function:

```python
pparams = np.array([0, 1, 1, 1])

@qml.qnode(dev2)
def circuitBasis(params):
    qml.BasisState(params, wires=[0, 1, 2, 3])
    return [qml.expval(qml.PauliZ(i)) for i in range(4)]

```

---

<div class="post-metadata">

**Author:** ![RX1](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/rx1/32/698_2.png) [@RX1](https://discuss.pennylane.ai/u/RX1)\
**Post date:** [October 8, 2021, 7:04am UTC](https://discuss.pennylane.ai/t/help-a-problem/1396/3 "2021-10-08T07:04:30Z")

</div>

thank you !!!

---

<div class="post-metadata">

**Author:** ![RX1](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/rx1/32/698_2.png) [@RX1](https://discuss.pennylane.ai/u/RX1)\
**Post date:** [October 8, 2021, 12:08pm UTC](https://discuss.pennylane.ai/t/help-a-problem/1396/4 "2021-10-08T12:08:19Z")

</div>

![image](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/1X/e49bfc8de69778079098bfd16fa3b49a408aa05a.png)

---

<div class="post-metadata">

**Author:** ![RX1](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/rx1/32/698_2.png) [@RX1](https://discuss.pennylane.ai/u/RX1)\
**Post date:** [October 8, 2021, 12:10pm UTC](https://discuss.pennylane.ai/t/help-a-problem/1396/5 "2021-10-08T12:10:22Z")

</div>

![image](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/1X/8ac7dea34c1c6971562356cda0283cb40b7bdc0b.png)

---

<div class="post-metadata">

**Author:** ![RX1](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/rx1/32/698_2.png) [@RX1](https://discuss.pennylane.ai/u/RX1)\
**Post date:** [October 8, 2021, 12:19pm UTC](https://discuss.pennylane.ai/t/help-a-problem/1396/6 "2021-10-08T12:19:32Z")

</div>

![image](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/1X/e04cc9179279bf397a50bf739f8e9d53c637b2fa.png)

 ![image](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/1X/f0716cfbe7b025e30ed71ad250b943c1ea9fb619.png)

---

<div class="post-metadata">

**Author:** ![josh](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/josh/32/100_2.png) [@josh](https://discuss.pennylane.ai/u/josh)\
**Post date:** [October 8, 2021, 1:58pm UTC](https://discuss.pennylane.ai/t/help-a-problem/1396/7 "2021-10-08T13:58:07Z")

</div>

Hi @RX1, if you want to use the Strawberry Fields devices, you will need to install the PennyLane-SF plugin:

```auto
pip install pennylane-sf

```
