# Syntax error with python expression

**URL:** <https://forum.inductiveautomation.com/t/syntax-error-with-python-expression/91248>\
**Category:** Ignition\
**Tags:** python\
**Created:** [June 2, 2024, 1:11am UTC](https://forum.inductiveautomation.com/t/syntax-error-with-python-expression/91248 "2024-06-02T01:11:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JVeldt](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@JVeldt](https://forum.inductiveautomation.com/u/JVeldt)\
**Post date:** [June 2, 2024, 1:11am UTC](https://forum.inductiveautomation.com/t/syntax-error-with-python-expression/91248/1 "2024-06-02T01:11:10Z")

</div>

Hi, I'm new to python and had a question about an error that I am getting  
I have two memory tags that are integer data type and they evaluate to either 1 or 0. I want a third component to set its visibility to true if both tags are 1, else false.

I have this expression worked out but am getting a syntax error message that I can't figure out.

expression:  
if (tag({[default]Password Bit}) == 1 and tag({[default]Username\_Bit}) == 1, 1, 0)

error message:  
Syntax Error on Token: 'EQUAL' (Line 1 , Char 35)

I don't know why that equals sign would be an issue?

Thanks

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [June 2, 2024, 1:16am UTC](https://forum.inductiveautomation.com/t/syntax-error-with-python-expression/91248/2 "2024-06-02T01:16:06Z")

</div>

Don't use double equals in an expression. In many programming languages, double equals are needed to differentiate comparison from variable assignment, but [expression language](https://www.docs.inductiveautomation.com/docs/8.1/platform/expression-language-and-syntax) doesn't work that way.

**Edit:** I also noticed that `and` is being used instead of `&&`, [Ignition's expression language](https://www.docs.inductiveautomation.com/docs/8.1/platform/expression-language-and-syntax) is not python, so there are some differences in syntax.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 2, 2024, 4:19am UTC](https://forum.inductiveautomation.com/t/syntax-error-with-python-expression/91248/3 "2024-06-02T04:19:18Z")

</div>

Also, you don’t need to (and probably shouldn’t) use the 'tag', expression. That expression is used to resolve a dynamic tag name to its value at runtime. Because you already know your tag names and they are static, your expression should simply be:

```python
{[default]Password Bit} && {[default]Username_Bit}

```

There are some other caveats to using the Tag expression function especially in a Vision application. Generally, stay away from it.

Also, as @justinedwards.jle noted, the expression language is not Python. It is its own language written by IA. The two languages can not be mixed (except for when they happen to share syntax).

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [June 2, 2024, 5:08am UTC](https://forum.inductiveautomation.com/t/syntax-error-with-python-expression/91248/4 "2024-06-02T05:08:28Z")

</div>

> [@lrose](#):
>
> use the 'tag', expression

Another option is to use tag bindings on custom properties and use the custom properties in the expression.

Laslty, if statements that return [true, false] or [1, 0] values are never needed because the condition for the if statement can always speak for itself in the expression.

---

<div class="post-metadata">

**Author:** ![JVeldt](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@JVeldt](https://forum.inductiveautomation.com/u/JVeldt)\
**Post date:** [June 3, 2024, 5:30am UTC](https://forum.inductiveautomation.com/t/syntax-error-with-python-expression/91248/5 "2024-06-03T05:30:04Z")

</div>

Thank you guys that helped alot
