# "Looping" a loop

**URL:** https://community.thunkable.com/t/looping-a-loop/1339687
**Category:** Questions about Thunkable X
**Tags:** beginner
**Created:** [June 11, 2021, 5:55pm UTC](https://community.thunkable.com/t/looping-a-loop/1339687 "2021-06-11T17:55:10Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![mimostel](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mimostel/32/107661_2.png) [@mimostel](https://community.thunkable.com/u/mimostel)
#### Post date: [June 11, 2021, 5:55pm UTC](https://community.thunkable.com/t/looping-a-loop/1339687/1 "2021-06-11T17:55:10Z")

</div>

Hello. I need an aproach strategy in thunkable to solve this kind of action:  
 ![01](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/e/4ea05d1e1b410154edcc6767cbe49e2e0502106f.png)  
The closest block i found in Thunkable for that is “count with i from x to y” so:

 ![02](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/c/9c0b2fc6f63784d57e42233fb213602c28f6871a.png)  
My problem is that on my secont count inside the first, i cannot change variable “i”… Renaming will change first too…  
Maybe count is not intended to solve this, and you will point me to other block 🙂 Thank you.

---

<div class="post-metadata">

### Author: ![sketch](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/sketch/32/109058_2.png) [@sketch](https://community.thunkable.com/u/sketch)
#### Post date: [June 11, 2021, 6:06pm UTC](https://community.thunkable.com/t/looping-a-loop/1339687/2 "2021-06-11T18:06:31Z")

</div>

Just create a new variabele and Use that one.  
The i in the loop is the same as the first.  
So it renames automaticly both.

---

<div class="post-metadata">

### Author: ![mimostel](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mimostel/32/107661_2.png) [@mimostel](https://community.thunkable.com/u/mimostel)
#### Post date: [June 11, 2021, 6:15pm UTC](https://community.thunkable.com/t/looping-a-loop/1339687/3 "2021-06-11T18:15:13Z")

</div>

im so dumb… and i was trying to make this selecting only from implicit list 😊

 ![01](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/6/76d69183bbf1c89ca193ec1abf2493c2eaad7167.png)  
thank you

---

<div class="post-metadata">

### Author: ![sketch](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/sketch/32/109058_2.png) [@sketch](https://community.thunkable.com/u/sketch)
#### Post date: [June 11, 2021, 6:48pm UTC](https://community.thunkable.com/t/looping-a-loop/1339687/4 "2021-06-11T18:48:04Z")

</div>

You’re welcome.

---

<div class="post-metadata">

### Author: ![mimostel](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mimostel/32/107661_2.png) [@mimostel](https://community.thunkable.com/u/mimostel)
#### Post date: [June 11, 2021, 7:45pm UTC](https://community.thunkable.com/t/looping-a-loop/1339687/5 "2021-06-11T19:45:00Z")

</div>

… but now i have another issue …  
lets say that i=2; j=3 … i have 6 items in generated list, but, in my example, list looks like:  
sector\_0\_stand\_0  
sector\_0\_stand\_0  
sector\_0\_stand\_0  
sector\_0\_stand\_0  
sector\_0\_stand\_0  
sector\_0\_stand\_0

instead of  
sector\_1\_stand\_1  
sector\_1\_stand\_2  
sector\_1\_stand\_3  
sector\_2\_stand\_1  
sector\_2\_stand\_2  
sector\_2\_stand\_3

so i, j reacts as numbers in count, but when trying to generate list, they keep initialized values 0  
🤨

---

<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 11, 2021, 7:57pm UTC](https://community.thunkable.com/t/looping-a-loop/1339687/6 "2021-06-11T19:57:08Z")

</div>

Nested loops can work in Thunkable but there are quite a few components that take too long to complete their code and don’t work inside of loops. You’re using a _stored_ variable which is a slower method of storing/retrieving data in Thunkable. I wonder what happens if you use an _app_ variable?

It’s very possible that you’re going to need to add some `Wait` blocks (possibly just wait 0 seconds) within the loop block(s) to slow things down.

Some very relevant info:

> [@Wrapping Asynchronous (then do) blocks into a Synchronous Function resolves unpredictable results](https://community.thunkable.com/t/wrapping-asynchronous-then-do-blocks-into-a-synchronous-function-resolves-unpredictable-results/910511):
>
> Thunkable provides an extensive library of calls to external services including Google Docs and Web APIs. These external calls are, by necessity, asynchronous calls. That is, the request is sent to the external serivce, Thunkable block execution continues on it’s merry way, then the external service sends a reply. Thunkable wraps the external calls in in blocks with “Then Do” sections. This is a massive improvement over separate call and response block (MIT App Inventor), but it is not without …

---

<div class="post-metadata">

### Author: ![mimostel](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mimostel/32/107661_2.png) [@mimostel](https://community.thunkable.com/u/mimostel)
#### Post date: [June 11, 2021, 8:10pm UTC](https://community.thunkable.com/t/looping-a-loop/1339687/7 "2021-06-11T20:10:50Z")

</div>

@muneer already teached me how to deal in case of asynchronous issues 😌  
but i dont think is the case here.  
anyway, i tried this too:

 ![01](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/4/a4e54e4dbd1771d7902a6ca699771c1358db070d.png)  
with the same null result

---

<div class="post-metadata">

### Author: ![mimostel](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mimostel/32/107661_2.png) [@mimostel](https://community.thunkable.com/u/mimostel)
#### Post date: [June 11, 2021, 8:42pm UTC](https://community.thunkable.com/t/looping-a-loop/1339687/8 "2021-06-11T20:42:44Z")

</div>

this works

 ![01](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0fbd2013462c5f9369a05e084930ecb0a9d0b0ef.png)

so i guess that count only works as a counter and those ii, jj variables dont keep values…  
so i imagine that i need other 2 variables to keep results, and it works

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [June 12, 2021, 11:02am UTC](https://community.thunkable.com/t/looping-a-loop/1339687/9 "2021-06-12T11:02:54Z")

</div>

@mimostel  
I know you already solved your issue but I wanted to highlight something which should save you from creating lots of variables.

The variables inside the loops and parameters of functions are special type of variables.  
You do not need to created `app variables` to use them as loop number holders.

When you add a loop block you can **click** on the variable to rename it like this,  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/2/32fe2c170ffa41d15fbca831ee37dda89b6bbfb4.png)

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/8/68b7e34b563308dc7f93e2414a301bca62432f4a.png)

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/3/436f07186e92f693502e8d4c65ec57cbe9b88d91.png)

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/5/c5319d09a5f4ac72eb826a96e471d8433f041c03.png)

Now you have a variable for the loop and is available as the **name** only without the **app variable** proceeding it.

---

<div class="post-metadata">

### Author: ![sketch](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/sketch/32/109058_2.png) [@sketch](https://community.thunkable.com/u/sketch)
#### Post date: [June 12, 2021, 12:05pm UTC](https://community.thunkable.com/t/looping-a-loop/1339687/10 "2021-06-12T12:05:52Z")

</div>

Yeah but using 2 loops with same variabele Will rename Both variabeles.

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [June 12, 2021, 12:07pm UTC](https://community.thunkable.com/t/looping-a-loop/1339687/11 "2021-06-12T12:07:18Z")

</div>

You can give each loop its own variable name in the same way I explained. I’m using it and I know it works.

---

<div class="post-metadata">

### Author: ![mimostel](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mimostel/32/107661_2.png) [@mimostel](https://community.thunkable.com/u/mimostel)
#### Post date: [June 12, 2021, 12:11pm UTC](https://community.thunkable.com/t/looping-a-loop/1339687/12 "2021-06-12T12:11:21Z")

</div>

well, thank you, but doesnt work for me… it still rename both… this kind of aproach was my 1st…  
maybe because i duplicate 1st loop for second when editing ? … ill retry now without duplicate and make second loop from the scratch

Later edit: yes, is working …

---

<div class="post-metadata">

### Author: ![sketch](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/sketch/32/109058_2.png) [@sketch](https://community.thunkable.com/u/sketch)
#### Post date: [June 12, 2021, 12:11pm UTC](https://community.thunkable.com/t/looping-a-loop/1339687/13 "2021-06-12T12:11:51Z")

</div>

Hmm that never really worked for me.  
I’ll check it out later this day.  
EDIT.  
Now i understand it.  
Haha  
Thanks @muneer

---

<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:20pm UTC](https://community.thunkable.com/t/looping-a-loop/1339687/14 "2024-11-08T13:20:20Z")

</div>


