# Do we have "not in" in RobotFramework?

**URL:** <https://forum.robotframework.org/t/do-we-have-not-in-in-robotframework/8643>\
**Category:** Robot Framework\
**Created:** [13 March 2025 12:52 UTC](https://forum.robotframework.org/t/do-we-have-not-in-in-robotframework/8643 "2025-03-13T12:52:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vitaly](https://avatars.discourse-cdn.com/v4/letter/v/838e76/32.png) [@Vitaly](https://forum.robotframework.org/u/Vitaly)\
**Post date:** [13 March 2025 12:52 UTC](https://forum.robotframework.org/t/do-we-have-not-in-in-robotframework/8643/1 "2025-03-13T12:52:44Z")

</div>

Hi!

I am trying to add new element to the list if it was not there before.

`Run Keyword If ${itemText} not in ${Infostring} Append To List ${Infostring} ${itemText}`

But i got error Evaluating expression ’ not in ’ failed: SyntaxError: invalid syntax  
How to solve this problem?

---

<div class="post-metadata">

**Author:** ![FrancisG](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/francisg/32/4247_2.png) [@FrancisG](https://forum.robotframework.org/u/FrancisG)\
**Post date:** [13 March 2025 13:08 UTC](https://forum.robotframework.org/t/do-we-have-not-in-in-robotframework/8643/2 "2025-03-13T13:08:01Z")

</div>

Yes we do, the syntax error is related to using `${var}` rather than `$var`, here is the correct syntax:

`Run Keyword If $itemText not in $Infostring Append To List ${Infostring} ${itemText}`

More explanations on what syntax is expected by [Run Keyword If](https://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Run%20Keyword%20If) for its condition: [Evaluating expressions](https://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Evaluating%20expressions)

Also `${Infostring}` must be a list for [Append To List](https://robotframework.org/robotframework/latest/libraries/Collections.html#Append%20To%20List) to be able to work with it.

See whole example working [on playground](https://robotframework.org/code/?codeProject=N4IgdghgtgpiBcIDCBXAzgFwPZQAQGMsATOAGhBLXwCcBLABw1qzARBHIDNaAbGNBAG1Q3PgDlocRBn4YAdNSwAjLBg4hCYGVrYAqfbgDKMDEzABzNLn26AOmAAytJdQjUAnri+4kWHn3wmFjR7extcABVZHwg0fmt9eyjMe29cADUAQQAlNIASYFoZKCiADwwAXzSimDxsXAgiIlTvLNzvAAFgAEkwTixMOgsqtN7+3EHaC1xuakxcGrxvOM0iBeKWr2yUMFwAaRh3AHcsajXuznzFsoxcMFUF3byxgYwh8zTM+noYMDWIrC4JzzbwFF6TYb5QrFG4VEAVAC65BIdAAbjAiAAFRQAKxggQQnAgPDi5EUKgw6Rgc2YrEQAHY5AAmZnqcmqTLUSwIYAVMkwACOKFo1FqvwwAngggRFSAA).

---

<div class="post-metadata">

**Author:** ![Noordsestern](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/noordsestern/32/4270_2.png) [@Noordsestern](https://forum.robotframework.org/u/Noordsestern)\
**Post date:** [14 March 2025 07:05 UTC](https://forum.robotframework.org/t/do-we-have-not-in-in-robotframework/8643/3 "2025-03-14T07:05:44Z")

</div>

Stylewise you could use a the `IF` statement which makes the line probably more readable:

```python
IF $itemText not in $Infostring Append To List ${Infostring} ${itemText}

```

That should work with Robot Framework \>=4

If you like, checkout the user guide for more information on IF/ELSE syntax at Robot Framework: [Robot Framework User Guide](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#if-else-syntax)
