# Postion and variable in a list

**URL:** <https://community.thunkable.com/t/postion-and-variable-in-a-list/2470698>\
**Category:** Issues / Bugs\
**Created:** [June 17, 2023, 9:20am UTC](https://community.thunkable.com/t/postion-and-variable-in-a-list/2470698 "2023-06-17T09:20:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefansladdeneng1](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/stefansladdeneng1/32/170123_2.png) [@stefansladdeneng1](https://community.thunkable.com/u/stefansladdeneng1)\
**Post date:** [June 17, 2023, 9:20am UTC](https://community.thunkable.com/t/postion-and-variable-in-a-list/2470698/1 "2023-06-17T09:20:01Z")

</div>

Hi all,  
Short q.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/3/83e0c492d19154940d6eb184f2ee88747c4841ce.png)  
The attached image seems to show something simple - If a certain condition does not apply  
Remove the item from a list - However i am not sure i get it right  
In the first part of the IF statement i ask if a certain string of text contain the **value** from “J”  
If true - All good  
But when i come to the second part i say that if the above is NOT true  
“J” Should be removed from list

This second time, i am referring to the item “J” as an item - Meaning a position in the list, should be removed as the Content of this item number does not comply with the first statement.  
So  
sometimes J refers to the position in the list - and  
sometimes J refers to the value it self.

So how shall i think doing this operation ?  
@tatiang - Any ideas… @ioannis ??

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [June 17, 2023, 9:27am UTC](https://community.thunkable.com/t/postion-and-variable-in-a-list/2470698/2 "2023-06-17T09:27:42Z")

</div>

There are two ways to loop through a list:

1. Use the `Count with from 1 to ____ ` block. The variable “j” represents an integer and can be used as a list item index #.

2. Use the `For each item in list` block. The variable “j” represents a list item. You will need to use a different variable and manually increment it by adding 1 during each loop iteration. Use that second variable as the list item index #.

---

<div class="post-metadata">

**Author:** ![stefansladdeneng1](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/stefansladdeneng1/32/170123_2.png) [@stefansladdeneng1](https://community.thunkable.com/u/stefansladdeneng1)\
**Post date:** [June 17, 2023, 12:50pm UTC](https://community.thunkable.com/t/postion-and-variable-in-a-list/2470698/3 "2023-06-17T12:50:57Z")

</div>

Thanks 😃 But sorry Tatiang… You lost me there…  
I am after a “For Each” operation and check the value behind each #item

Lets say list with items as follows  
1 = Banana  
2 = Apple  
3 = Pear  
4 = Orange

Using For Each for List X i should expect

1. If Banana exist in another string of text - And it is - Good, then let “Banana” remain in list
2. If Apple exist in another string of text - And it is - Good, then let “Apple” remain in list
3. If Pear exist in another string of text - And it is NOT - Sorry, then “Pear” should **NOT** remain in list  
so i then use From List X - Remove item 3  
And then i expect the “For Each” operation to continue…  
How can i achieve that…?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [June 17, 2023, 2:24pm UTC](https://community.thunkable.com/t/postion-and-variable-in-a-list/2470698/4 "2023-06-17T14:24:02Z")

</div>

Create a variable called loopCount. Set it to 0 above the loop block. Inside the loop, change it by 1. For your in list remove block, use loopCount instead of j.

---

<div class="post-metadata">

**Author:** ![stefansladdeneng1](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/stefansladdeneng1/32/170123_2.png) [@stefansladdeneng1](https://community.thunkable.com/u/stefansladdeneng1)\
**Post date:** [June 17, 2023, 2:31pm UTC](https://community.thunkable.com/t/postion-and-variable-in-a-list/2470698/5 "2023-06-17T14:31:44Z")

</div>

Do you mean that J does allways, and without exception refers to the content…  
rather than item and items number?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [June 17, 2023, 2:59pm UTC](https://community.thunkable.com/t/postion-and-variable-in-a-list/2470698/6 "2023-06-17T14:59:00Z")

</div>

When you use a `For each item` block, j only and always refers to the list item’s value.

So if you loop through the list {“A”, “B”, “C”}, the second time through the list, j will have the value “B”. It will never have the value 2, for example.

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:33pm UTC](https://community.thunkable.com/t/postion-and-variable-in-a-list/2470698/7 "2024-11-08T13:33:49Z")

</div>


