# String error for expression

**URL:** <https://discourse.mcneel.com/t/string-error-for-expression/210753>\
**Category:** Grasshopper\
**Tags:** windows\
**Created:** [October 8, 2025, 9:04pm UTC](https://discourse.mcneel.com/t/string-error-for-expression/210753 "2025-10-08T21:04:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![user135](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/user135/32/637069_2.png) [@user135](https://discourse.mcneel.com/u/user135)\
**Post date:** [October 8, 2025, 9:04pm UTC](https://discourse.mcneel.com/t/string-error-for-expression/210753/1 "2025-10-08T21:04:13Z")

</div>

can anyone tell me what is wrong here?

1. Expression generated an error for (x, y): Operator \> not defined for string and int

 ![Capture](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/c/f/f/cff6594b8ea1ce9c10690b2dc4a51d2001c52c55.jpeg)

---

<div class="post-metadata">

**Author:** ![martinsiegrist](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/martinsiegrist/32/772775_2.png) [@martinsiegrist](https://discourse.mcneel.com/u/martinsiegrist)\
**Post date:** [October 8, 2025, 9:15pm UTC](https://discourse.mcneel.com/t/string-error-for-expression/210753/2 "2025-10-08T21:15:25Z")

</div>

![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/d/1/6/d16cdbdd1d1c5a9dc3f00f4187ee4c5704a3e525.png)

This works. I think you need parenthesis and ‘and’ instead of ‘&’

---

<div class="post-metadata">

**Author:** ![Ali\_Najmaei](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ali_najmaei/32/636031_2.png) [@Ali\_Najmaei](https://discourse.mcneel.com/u/Ali_Najmaei)\
**Post date:** [October 8, 2025, 9:37pm UTC](https://discourse.mcneel.com/t/string-error-for-expression/210753/3 "2025-10-08T21:37:49Z")

</div>

Hi my friend , as dear Martin explained earlier ,

> [@martinsiegrist](#):
>
> you need parenthesis and ‘and’ instead of ‘&’

This file may help :  
[Expression-question.gh](https://discourse.mcneel.com/uploads/short-url/ckoaakJsclmhQJ7RMvsheLr31y7.gh) (3.1 KB)

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/c/3/f/c3f3f5905881a9aba4022046f7666c99224f33f7.png)

Cheers !

P.S. Also you can consider using python in these cases :

```python
a = []
for i in range(len(x)):
    if (x[i] > 200) & (y[i] > 2000):
        value = 0
    elif (x[i] > 150) & (x[i] <= 200) & (y[i] > 1200) & (y[i] <= 2000):
        value = 1
    elif (x[i] < 150) & (y[i] < 1000):
        value = 2
    else:
        value = -1
    a.append(value) 

```

---

<div class="post-metadata">

**Author:** ![user135](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/user135/32/637069_2.png) [@user135](https://discourse.mcneel.com/u/user135)\
**Post date:** [October 8, 2025, 10:03pm UTC](https://discourse.mcneel.com/t/string-error-for-expression/210753/4 "2025-10-08T22:03:46Z")

</div>

many thanks of both you @Ali_Najmaei @martinsiegrist
