# For each item fails to work

**URL:** <https://community.thunkable.com/t/for-each-item-fails-to-work/2287934>\
**Category:** Questions about Thunkable X\
**Created:** [February 21, 2023, 2:15am UTC](https://community.thunkable.com/t/for-each-item-fails-to-work/2287934 "2023-02-21T02:15:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anandavardhana57zwwl](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@anandavardhana57zwwl](https://community.thunkable.com/u/anandavardhana57zwwl)\
**Post date:** [February 21, 2023, 2:15am UTC](https://community.thunkable.com/t/for-each-item-fails-to-work/2287934/1 "2023-02-21T02:15:15Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/b/8b053bdff9339651f114beb66fa435a0926bc504.png)  
ProbList = 8,4,7,5,7,6,5,2,1,3,6,8,4,9,4,6,9,8,6,4  
Length = 20  
When I use “count” I get all the list items listed correctly from 8, 4, … 6, 4  
I remove the “count” and replace it with a “for” and that lists haphazardly like 2, 5, 7, 5, 6 , 7, 4, 8 …  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/1/01d2e0ac42c7194e9bb149128d3a71ffa33f3328.png)  
What a I missing. Please advice

---

<div class="post-metadata">

**Author:** ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)\
**Post date:** [February 21, 2023, 2:58am UTC](https://community.thunkable.com/t/for-each-item-fails-to-work/2287934/2 "2023-02-21T02:58:54Z")

</div>

when you use **for** the variable **j** already contains the item in the array - you are trying to use j as an index to the array!  
here’s what you get for the first iterations of **for** and , based on your usage, the corresponding item in the same array!  
iter1 , j=8, 8th parameter of Problist → 2  
iter2 , j=4, 4th parameter of Problist → 5  
iter3 , j=7, 7 th parameter of Problist → 7  
iter4 , j=4, 4 th parameter of Problist → 5  
etc.  
that;s why your output is 2,5,7,5,…

just change your set statement to use **j** directly  
**set**"Error txt"s **text** to **“j”**

---

<div class="post-metadata">

**Author:** ![anandavardhana57zwwl](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@anandavardhana57zwwl](https://community.thunkable.com/u/anandavardhana57zwwl)\
**Post date:** [February 21, 2023, 3:37am UTC](https://community.thunkable.com/t/for-each-item-fails-to-work/2287934/3 "2023-02-21T03:37:55Z")

</div>

Sorry sorry so silly of me. You are right, thank you very much. The documentation is also right. I wish Thunkable would give bit more detailed information with a working simple example. Thanks again

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [May 22, 2023, 3:38am UTC](https://community.thunkable.com/t/for-each-item-fails-to-work/2287934/4 "2023-05-22T03:38:52Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
