# \[Solved\] How can i Generate a random number without repeat

**URL:** <https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046>\
**Category:** Questions about Thunkable X\
**Tags:** solved, question, random-number, non-repeating\
**Created:** [February 20, 2020, 11:49am UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046 "2020-02-20T11:49:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![3bdoamir1](https://avatars.discourse-cdn.com/v4/letter/3/5f9b8f/32.png) [@3bdoamir1](https://community.thunkable.com/u/3bdoamir1)\
**Post date:** [February 20, 2020, 11:49am UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/1 "2020-02-20T11:49:39Z")

</div>

i am creating app which take form local Db the Row randomly

the the row can be repeated many times Because The random Number is repeatd i want to choose the same nuber Just one Time

---

<div class="post-metadata">

**Author:** ![kartik14](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/kartik14/32/44782_2.png) [@kartik14](https://community.thunkable.com/u/kartik14)\
**Post date:** [February 20, 2020, 12:03pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/2 "2020-02-20T12:03:10Z")

</div>

Hi, @3bdoamir1! 👋  
**Welcome to our community! 😊**

For this, you would need to store the used numbers in a list, and everytime generating a new random no., only accept it if it’s not in the _used numbers_ list.

* * *

First try applying this method yourselves, and tell us the result. If you stuck, we’ll help you out 🌟

Good Luck! 🎉  
Thanks! 😊

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [February 20, 2020, 12:52pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/3 "2020-02-20T12:52:16Z")

</div>

To piggyback off @kartik14, I would get a super long list Of integers from [random.org](http://random.org)

---

<div class="post-metadata">

**Author:** ![3bdoamir1](https://avatars.discourse-cdn.com/v4/letter/3/5f9b8f/32.png) [@3bdoamir1](https://community.thunkable.com/u/3bdoamir1)\
**Post date:** [February 20, 2020, 12:54pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/4 "2020-02-20T12:54:42Z")

</div>

thanks for answer i did it already but i dont understand list i am new

 ![2](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/0/30b386a523b84ba2e3a07c0c362c1f571dd62eed.jpeg)

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [February 20, 2020, 1:04pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/5 "2020-02-20T13:04:34Z")

</div>

cqn You describe more about your app? I’m not sure I understand what you are trying to do after rereading everything. Do you want the row from localDB to be deleted? Or just not used until all rows have been used at least once?

If that’s the case there is a special block just for that.

In my quiz app, I take all of the questions from local dB, put them into an ‘app’ type variable I call tempList. Then as my quiz steps through each question, instead of getting it from the localDB, I pull the question from var ‘app tempList’. I use the blue list block that says “get and remove #”. Then the app ends when ‘app tempList is empty.

The next time the user want to take that quiz to study, all or the questions are reloaded into ‘app tempList’ and the process starts over again

---

<div class="post-metadata">

**Author:** ![3bdoamir1](https://avatars.discourse-cdn.com/v4/letter/3/5f9b8f/32.png) [@3bdoamir1](https://community.thunkable.com/u/3bdoamir1)\
**Post date:** [February 20, 2020, 1:14pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/6 "2020-02-20T13:14:27Z")

</div>

I just to make a random number say from 1 to 100 not repeated every btn click like 18 btn click the variable becom 16 \>\>\> btn click the variable become 98 btn click the variable become 15  
i want the variable change every click not( 18 \>16\>\> then 18 again)

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [February 20, 2020, 1:37pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/7 "2020-02-20T13:37:38Z")

</div>

Does that happen when you use the random integer block?

The thing about randomness is that your odds that you will get the same number two times in a row are just as likely as getting a different number. are just as likely to get the same number as any other number.

---

<div class="post-metadata">

**Author:** ![3bdoamir1](https://avatars.discourse-cdn.com/v4/letter/3/5f9b8f/32.png) [@3bdoamir1](https://community.thunkable.com/u/3bdoamir1)\
**Post date:** [February 20, 2020, 1:45pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/8 "2020-02-20T13:45:39Z")

</div>

I Know its Just example \>\> what i want make the variable a number and never repeat again when i click btn i want like that it i press btn the variable change every click like random number from 1 to 10 (1.4.8.6.5.3.2.,10,9,7) no repeat numbers every btn change avariable to new number

---

<div class="post-metadata">

**Author:** ![3bdoamir1](https://avatars.discourse-cdn.com/v4/letter/3/5f9b8f/32.png) [@3bdoamir1](https://community.thunkable.com/u/3bdoamir1)\
**Post date:** [February 20, 2020, 1:51pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/9 "2020-02-20T13:51:37Z")

</div>

> [@kartik14](#):
>
> For this, you would need to store the used numbers in a list, and everytime generating a new random no., only accept it if it’s not in the _used numbers_ list.

that what i want to do but i cant can u help me pls

---

<div class="post-metadata">

**Author:** ![kartik14](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/kartik14/32/44782_2.png) [@kartik14](https://community.thunkable.com/u/kartik14)\
**Post date:** [February 20, 2020, 1:55pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/10 "2020-02-20T13:55:41Z")

</div>

Hi, @3bdoamir1! 👋

Try these blocks -

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

Thanks! 😊

---

<div class="post-metadata">

**Author:** ![3bdoamir1](https://avatars.discourse-cdn.com/v4/letter/3/5f9b8f/32.png) [@3bdoamir1](https://community.thunkable.com/u/3bdoamir1)\
**Post date:** [February 20, 2020, 2:38pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/11 "2020-02-20T14:38:19Z")

</div>

My browser crush when i try it  
the link  
[https://x.thunkable.com/copy/d3168f449d89b1426a6302d4084d7222](https://x.thunkable.com/copy/d3168f449d89b1426a6302d4084d7222)

---

<div class="post-metadata">

**Author:** ![kartik14](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/kartik14/32/44782_2.png) [@kartik14](https://community.thunkable.com/u/kartik14)\
**Post date:** [February 20, 2020, 2:46pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/12 "2020-02-20T14:46:44Z")

</div>

Hi, @3bdoamir1! 👋

Very sorry to inform, I had mistake in my code 😓

Please try this one, this works brilliantly for me -

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

Apologies 🙂  
Thanks! 😊

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [February 20, 2020, 3:13pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/13 "2020-02-20T15:13:32Z")

</div>

This task has been solved more than once on the forum.

1. Upload all data from the source to the list
2. Get the number of rows in the list
3. Generate a random index of an element from this range
4. Get the row element by this index
5. Delete a list item by this index

Repeat steps 2-5 if the list is not empty

---

<div class="post-metadata">

**Author:** ![3bdoamir1](https://avatars.discourse-cdn.com/v4/letter/3/5f9b8f/32.png) [@3bdoamir1](https://community.thunkable.com/u/3bdoamir1)\
**Post date:** [February 20, 2020, 3:57pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/14 "2020-02-20T15:57:29Z")

</div>

i want to make iq test 200

> [@kartik14](#):
>
> Please try this one, this works brilliantly for me -

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

thats really what i want but try it with 5 numbers rather than 100  
u will find the number repeat

---

<div class="post-metadata">

**Author:** ![3bdoamir1](https://avatars.discourse-cdn.com/v4/letter/3/5f9b8f/32.png) [@3bdoamir1](https://community.thunkable.com/u/3bdoamir1)\
**Post date:** [February 20, 2020, 4:38pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/15 "2020-02-20T16:38:49Z")

</div>

sorry i am new \>\> i want to do iq test 30 qustion from 200(after 30 its end ) every time you answer its replace questions and answers all done \>\> now when i make it choose questions randomly it may repeat some qeustions i want to make a variable with every btn click it change to new value (not repeat any old ) can u help me with blocks to make random variable every click no repeat

---

<div class="post-metadata">

**Author:** ![Dean\_Artis](https://avatars.discourse-cdn.com/v4/letter/d/a8b319/32.png) [@Dean\_Artis](https://community.thunkable.com/u/Dean_Artis)\
**Post date:** [February 20, 2020, 9:52pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/16 "2020-02-20T21:52:46Z")

</div>

Search the forum. This has been solved before.

---

<div class="post-metadata">

**Author:** ![3bdoamir1](https://avatars.discourse-cdn.com/v4/letter/3/5f9b8f/32.png) [@3bdoamir1](https://community.thunkable.com/u/3bdoamir1)\
**Post date:** [February 20, 2020, 10:43pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/17 "2020-02-20T22:43:43Z")

</div>

I found extension . aia i cant use them or a written and i am new so i cant do it co u help me

---

<div class="post-metadata">

**Author:** ![Dean\_Artis](https://avatars.discourse-cdn.com/v4/letter/d/a8b319/32.png) [@Dean\_Artis](https://community.thunkable.com/u/Dean_Artis)\
**Post date:** [February 20, 2020, 11:05pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/18 "2020-02-20T23:05:25Z")

</div>

All you need to do is create a list with the numbers 1-100 (or however many records you have).

Select a number at random from it and remove it from the list.

This way every number will be unique.

---

<div class="post-metadata">

**Author:** ![3bdoamir1](https://avatars.discourse-cdn.com/v4/letter/3/5f9b8f/32.png) [@3bdoamir1](https://community.thunkable.com/u/3bdoamir1)\
**Post date:** [February 20, 2020, 11:30pm UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/19 "2020-02-20T23:30:52Z")

</div>

i tried but i dont understand list

 ![random list](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/c/cc102c23a91228c7bec47ce4e957f75ab16a8a1b.png)  
it doesnt work

…

 ![2](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/5/45a5bcc784290e04a21cad0f253f8c5e491270d1.jpeg)

it doesnt work

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [February 21, 2020, 7:00am UTC](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046/20 "2020-02-21T07:00:10Z")

</div>

Check it

![изображение](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/a/fa7a384fbf1bd28c77329167aa32c4461015816b.png)

[Next page](https://community.thunkable.com/t/solved-how-can-i-generate-a-random-number-without-repeat/475046.md?page=2)
